Hello all, I need ur help in below work, I need to made search operation depending upon keywords typed in the text box, and also in results i highlighted with red the search keywords. The problem in this is the search keywords are highlighted with case sensitive. That is, when i type 'html' to search, in the result 'HTML' is not highlighted. I need to highlighted the result with an incase sensitive keyword. My coding is as follows: $searchtxt=stripslashes($_REQUEST[txtSearch]); //$searchtxt1=addslashes(htmlspecialchars($searchtxt)); //echo $searchtxt1=addslashes(htmlspecialchars($searchtxt)); $sql="SELECT * FROM page_content WHERE (modelno LIKE '%$searchtxt%') or (prodname LIKE '%$searchtxt%') or (proddesc LIKE '%$searchtxt%') or (prodfeature LIKE '%$searchtxt%') or (prodspec LIKE '%$searchtxt%')"; $res=mysql_query(getPagingQuery($sql))or die(mysql_error()); $num=mysql_num_rows($res); $i=1; if($num!=0) { while($row=$db->fetch_array($res)) { $pname=stripslashes($pname); $pdesc=stripslashes($row[proddesc]); $pdesc=str_replace($t,"<b><font color=red>".$searchtxt."</font></b>",$pdesc); echo "<p align='justify'><a href=getcontent.php?mcid=$row[mcid]&scid=$row[scid]><font size='2'><u>$i.$row[modelno]. $pname</u></font></a></span><br/><br>$pdesc<br/></p>"; $i=$i+1; } PHP: Please help me if u know the answer
to add to that - make sure that $searchtxt is already lower $searchtxt=stripslashes($_REQUEST[txtSearch]); make $searchtxt=strtolower(stripslashes($_REQUEST[txtSearch]));
Thanks for ur reply. now i changed my coding as below. But it' not working.when when i type 'dvd' DVD is not highlighted $t=$_REQUEST[txtSearch]; // $searchtxt=stripslashes($_REQUEST[txtSearch]); echo $searchtxt=strtolower(stripslashes($_REQUEST[txtSearch])); //$searchtxt1=addslashes(htmlspecialchars($searchtxt)); //echo $searchtxt1=addslashes(htmlspecialchars($searchtxt)); $sql="SELECT * FROM page_content WHERE (lower(modelno) LIKE '%$searchtxt%') or (lower(prodname) LIKE '%$searchtxt%') or (lower(proddesc) LIKE '%$searchtxt%') or (lower(prodfeature) LIKE '%$searchtxt%') or (lower(prodspec) LIKE '%$searchtxt%')"; $res=mysql_query(getPagingQuery($sql))or die(mysql_error()); $num=mysql_num_rows($res); $i=1; if($num!=0) { while($row=$db->fetch_array($res)) { $pname=stripslashes($pname); $pdesc=stripslashes($row[proddesc]); $pdesc=str_replace($searchtxt,"<b><font color=red>".$searchtxt."</font></b>",$pdesc); echo "<p align='justify'><a href=getcontent.php?mcid=$row[mcid]&scid=$row[scid]><font size='2'><u>$i.$row[modelno]. $pname</u></font></a></span><br/><br>$pdesc<br/></p>"; $i=$i+1; } PHP: