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: [PHP]$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:
Hello balasun, Use the str_ireplace() function instead of str_replace(). it will ignore the case-sensitive.
Thanks for ur reply, i used str_ireplace() in my coding ,it's working good in text. but when i type number like 32" HD TV then in result does not highlighed 32" HD TV does not highlighted. Is there any way for these?
I'm not sure I understand you, give a more specific example (maybe some sample code). I guess you get a syntax error, cause you didn't escape the character " in the search term. Make it \" and try again