:: HOME » PHP » How can I highlight search words in search results?
 
How can I highlight search words in search results?

or my site I expect when user search results will be highlights (their search words). my present search box code below (this in an widget please give me full code)

<p align="center"><form id="searchthis" action="/search" style="display:inline;" method="get"> <input id="search-box" name="q" size="25" type="text"/> <input id="search-btn" value="Search" type="submit"/> </form></p>

For PHP WEBsite you can use below code but please check database document for it. I assume that you are searching in text field

 
 
Code<?PHP
$db->query("SELECT * FROM table WHERE text LIKE '%".$db->check($_GET['q'">)."%'");
if($db->num_rows()>0)
{
while($result = $db->fetch_array())
{
echo "<div>".str_replace($_GET['q'">,"<font color=red>".$_GET['q'">."</font>",$result['text'">)."</div>";
}
}
else
echo "No Result!";
?>
 
 
NEW ANSWER
 
Your E-Mail Address
»
Your e-mail will never be shown!  
   
 
Answer
»
Please type your ANSWER and please use [CODE] tag for your codes!  
  Add CODE Quote BOLD ITALIC Underline Align Left Align Center Align Right Add Line  
   
 
Human Check
»
Enter human check code below!  
   
 
       
 
 
Quaware Internet Solutions And Consulting - SEO Search Engine Optimization, Website development and design, eCommerce, Online Payment Systems, Shopping Cart, Affiliates Website Designer, Search Engine Optimization Expert, Ajax Developer,Developed And Designed By Mumin Celik With Using PHP, MySQL, CSS, JavaScript, Ajax And Search Engine Optimizer Sinema, Film, Ask, Tekgul, Mutluluk