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 in the middle of homework work and I'm stuck. At this point in my code, I think that I should have a GUI window that opens and allows me to type "inserted text number". Notice is not going anywhere but at this point, If I pass through the problem then it will be in a linked list. I am getting two of the same error for the lines. Add (index, element); And I can not seem to get past it, there is no suitable method for the error "add (int, java. string string)". Code is below, please advise. To clarify - this will not be a method error because it is a linked list. There should not be any way involved. import java.awt. *; Import java.awt.event. *; Import javax.swing. *; Import java.util. *; Import java.util.Scanner; Import java.util.LinkedList; Public class TopTenList JFrame {Private TopTenList tt; See the Private JTextArea list; Private JTextField cmdTextField; Private JTextField resultsTestfield; // This GUI window is the code for the public toptist...
I am using JPA 2.0 and getting the following code in the DAO layer: Public Zero Test () {string key = "status"; String [] Conditions = {"A", "B"}; & Lt; TestTable & gt; Results = Search (Keys, Conditions); } Public listing & lt; TestTable & gt; Search (string key, object value error) {string sql = "test ndf to testlet and jade nand." + Key + "in:" + key; TypedQuery & LT; TestTable & gt; Query = entityManager.createQuery (SQL, TestTable.class); Query.setParameter (key, Arrays.asList (valueArr)) / *** Error Line *** Return query.getResultList (); } In the above error line, it throws the following exception: java.lang.IllegalArgumentException: parameter value element [[Ljava.lang.String; @ cbe5bc] did not match the expected type [java.lang.String] Why is this expected type string while actually this string []? Please help! Note: This is derived from the normal routine and is a simplified code. I can no...
Yes, I know, there is a question with almost the same title, but it refers to a different situation. Error message) In my case, I have a .cpp file with a big named designation name (implementation details). There is a property class template with a static data member in that name space, which I need to access from outside the unknown namespace. I give it a little bit of meat: file.hpp namespace Bar {template & lt; Typename A & gt; Struct foo {static_assert (is_same & lt; a, float & gt; :: value} is_same & lt; a, double>: value, ""); Fixed zero set_static_var (a const & x); // ...}; } and file.cpp namespace {template & lt; Typename A & gt; Struct foo_traits {// supports the implementation of several static code bars: foo & lt; & Gt; Fixed A data; }; The template's & lt; & Gt; Float foo_traits & lt; Float & gt; :: datum; // No change if this is in the global namespace template & lt; & Gt; Doub...
|
Comments
Post a Comment