QAds
Apple iPad 64gb Wi-Fi 3G
$0.78
Sony Ericsson T715 Slider 3G Phone in Rouge Pink
$149.96
Coby 2.8-Inch LCD Touchscreen Video MP3 Player
$52.49
Apple iPad 64gb Wi-Fi 3G
$0.78
:: 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!  
   
 
       
 
 
mc sinema sudoku