Help me in this work.Pls..

Discussion in 'PHP' started by balasun, Aug 6, 2008.

  1. #1
    Hello all,

    I need ur's help in the below work,

    I need to made search the DB in incase-sensitive manner and want to highlighted the keyword in the search result in also incase-sensitive .

    But for sample i got one result for the keyword 'dvd' and for the other result for the keyword 'DVD'.

    In search keyword highlighting i used str_ireplace. But it changed in the result 'DVD' to 'dvd' or 'dvd' to DVD and highlighted.

    So i need to made if i search 'DVD' and i want to get the result which is same for 'dvd'. (incase-sensitive search).

    And in highlight process if my keyword is 'DVD' means i want to highlight 'DVD' and also 'dvd' in the result.(in case sensitive).

    My coding are as follows:
    $t=$_REQUEST[txtSearch];//search keyword
    	 $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_ireplace($t,"<b><font color=red>".$t."</font></b>",$pdesc);
    	echo "<p align='justify'><a href=getcontent.php?mcid=$row[mcid]&scid=$row[scid]><font size='2'><u>$i.$row[modelno].&nbsp;$pname</u></font></a></span><br/><br>$pdesc<br/></p>";
    	$i=$i+1;
    	}
    PHP:
    Please help me if u know the answer.
     
    balasun, Aug 6, 2008 IP