I am writing a search query for the items in my cart. The problem is I am not getting the expected result. Here is the code:
$here = explode(" ",$sarc);
$query = "SELECT * FROM 126link WHERE (";
foreach($here as $each){
$i++;
if($i==1)
$query.="title LIKE '%$each%') AND loginid = '$myid' ";
else
$query.="OR title LIKE '%$each%') AND loginid = '$myid' ";
}
$ritw = mysql_query($query);
$sup = @mysql_num_rows($ritw);
$query.="ORDER BY idl LIMIT 40";
$query = mysql_query($query);
$numrows = @mysql_num_rows($query);
I want to add an AND condition in this query which will search if idcolumn(in table) = '$id'
, but I don't know where to put it.
The code above displays results for all carts, I'm trying to limit it to one.