I am trying to show the highlighted word in red to a user when a user searches for a name in the database , Here's the code: echo "& lt; table class = 'name list' & gt;"; Echo "& lt; tr & gt; & lt; h3 & gt; You searched for & lt; Span class = 'Red' & gt; $ query & lt; / span & gt; ... please find the details . & Lt; / h3 & gt; & lt; / tr & gt; "; Echo "<<<< gt >> United Nations | Full Name & lt; / tr & gt; "; $ Result = mysql_query (Select "United Nations, NAME mytable from WHERE ('%.' $ Query"% 'like' NAME ') ") or die (mysql_error ()); if (mysql_num_rows ($ result)> gt; ; 0) {While ($ result = mysql_fetch_array ($ result)) {resonant "& lt; Tr & gt; & Lt; Td> ". $ Result ['United Nations]]." & Lt; / Td> & Lt; TD & gt; & Lt "$ result ['name'] .."; / TD & gt; & Lt; / TR & gt; & Lt; span class = 'red' & gt; $ query & lt; / span & gt; Try Again! & Lt; / td> & lt;; & lt; ; Tr & gt; "; Echo "& lt; / table & gt;"; before you can use the process on results When the result comes from the database, you will need to find your query in the result and replace it with the span which is red or what you want. In the example I have the background-color = yellow; , you can call it color = red; // Create a function, highlight a list of words in the string. Function Highlight Words ($ string, $ word) {// One word foreach ($ word as word $ word) {// foreign word keyword as word} and replace it with background color = yellow, if you want Then change it to red color, $ string = str_ireplace ($ word, '& lt; span style = "background-color: yellow" & gt;'. $ Word. '& Lt; / span & gt;', $ string ); } // Return string return $ string; } // Specify the words that you are looking for for $ word = array ("zebra"); // Your String $ string = "My name Zebra, Will Zebra do this?"; // Highlight $ string = highlightwords ($ string, $ word); // echo $ string; Here is the result: here
Popular posts from this blog
I'm trying to pass an input text from the viewer to the controller in the Facebook Birthday app: Link to app: In the Home Controller [FacebookAuthorize ("email", "user_photos")] Public async Tasks & lt; ActionResult & gt; Index (FacebookContext reference) {if (ModelState.IsValid) {var user = waiting for reference. Client.Gate CurrentUserAsync & lt; MyAppUser & gt; (); View return (user); } See Return ("Error"); } [Http post] [facebook authorized ("email", "user_photo")) public async task & lieutenant; Actionsclass & gt; Index (string textile, facebookcontonte context) {if (ModelState.IsValid) {var user = wait context.Client.GetCurrentUserAsync & lt; MyAppUser & gt; (); // See my code, see the use of txt here (user); } See Return ("Error"); } View: @using facebookpostc.models @ Microsoft.AspNet.Mvc.Facebook.models using @ Microsoft.AspNet.Mvc. Facebook @model MyAppUser @ {ViewB...
I have used 2 database tables and core data / NSManagedObjects in SQLite: User is user_id name group (multiple groups) Group group_id title group members (multiple users) By using core data to save a group and adding users ( Add to group) as follows: group * cordata = zero; Cordata = [NSEntityDescription insertNewObjectForEntityForName: @ Managed Object Contains in "Groups": Reference]; Request = [NSFetchRequest fetchRequestWithEntityName: @ "user"]; Request.predicate = [NSPredicate predicateWithFormat: @ "user_id =% @", user_id]; Result = [reference executeFetchRequest: request error: & amp; Error]; CoreData.group_id = group_id Cordettitle = Title [Cordata AdGroupMailersObject: [Last objections result]]; Is it right to say that core data manages a user with multiple users and groups with the code above? Yes, if the relationships are in the form of each other's inverse relationship The inverse relationships are updated automaticall...
I am calling a string with a C + code and calling from the C # code. The C ++ function is responsible for filling the string material. The following code is: C #party: var abc = new string builder (4096); // will have to change this var result = Basic methods. SignCrcFile (ABC); C ++: bool __cdecl SignCrcFile (char * abc) {... char * tempStr = "hello all"; // for example // copy it to ABC string strcpy (ABC, tempStr); Back true; } The problem is that tempStr's size in the C ++ function is dynamic (the above assignment for TempStr is only an example). In such a case, it is not a hard code that the size of ABC string is in the size of 4096 bytes on the C #. The first solution can be a solution to create 2 functions on the C ++ side to get the size of the string. Then allocate that size using StringBuilder in the C # side then use the next function to bring the entire string from C ++ to the C #. But no suggestion this may not be the most optimal way? ...
|
Comments
Post a Comment