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 have a big code, for a game I'm calling Tommy's Kumamak. I know that this is not beautiful, but I am very naive and for some reasons I know from using arrays, anyway, my problem is that I can not add a variable outside the listener and within the action listener I can modify the variable (pTurn ++) from How can I go about adding a count to that variable from inside the action listener? 1 error was found: file: c: \ user \ public \ togiz_kumalak.java [line: 130] error: local variables pTurn is accessed from within internal class; Need to be declared final int pTurn = 0; Button1.addActionListener {new zero-action action (action event e) {pTurn ++; if (pTurn% 2 == 0) {display.append ("\ n Player 2 cup 1");} If ( PTurn% 2! = 0) {display.append ("\ nPlayer 1Cup 1")}}); In that case, move the contents of the functionalities into orbit and then call the action For example, display the method from: Private Zero Button Press {pTurn ++; If (pTurn% 2...
I tried to use custom-made YouTube fun cats when I ran 5 cell arrays in 30 seconds and then a Throwing a serious error. I tried to know that I have been made an infinite loop, but he did not install it. iPhone 5S 32GB [Price] => 0 [Description] => A new apple product [Image_URL] = & Gt; [Business_ID] = & gt; 6 [keyword] = & gt; ["iPhone", "iPhone 5s", "Apple", "32 GB"]) [1] = & gt; array ([name] = & Gt; iPhone 4S 32g [Price] => 300 [Description] => Apple iPhone 4S = [Image_URL] => [Business_ID] => 6 [Keyword] = & gt; [ "IPhone 4S", "" iPhone "," Apple "," 32 GB "])) search: $ searchTerm =" iphone 5s "; Code: if (! SearchTerm below!) {$ SearchTermWords = Explosion (" ", $ searchTerm); $$ $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ ['Keyword']; $ bKeywords = $...
I am new to programming with C, and I need elsewhere that I can read on file compression in C I am I only need a simple accredited method, for example it will help but mostly I can read it to understand. Probably a good starting point RLE is very simple but it is not so insignificant to apply see it :
|
Comments
Post a Comment