$terms = explode(" ", $_GET["items"]);
$query = "SELECT * FROM warehouse WHERE";
$numterms = count($terms);
for($b = 0; $b < $numterms; $b++) {
$terms[$b] = trim($terms[$b]);
if($b > 0) {
$query .= " OR";
}
$query .= " items LIKE '%" . $terms[$b] . "%'";
$query .= " and listid LIKE '%" . $listid . "%'";
$query .=" and listed LIKE '1'";
$query .=" order by active desc, listed desc";
$results=mysql_query($query) ;
}
This code is for searching my database with multiple keywords, but it only can enter one key word at a time for searching, if enter 2 keywords it will return no results. Anyone here can tell me how to solve this problem?
$query = "SELECT * FROM warehouse WHERE";
$numterms = count($terms);
for($b = 0; $b < $numterms; $b++) {
$terms[$b] = trim($terms[$b]);
if($b > 0) {
$query .= " OR";
}
$query .= " items LIKE '%" . $terms[$b] . "%'";
$query .= " and listid LIKE '%" . $listid . "%'";
$query .=" and listed LIKE '1'";
$query .=" order by active desc, listed desc";
$results=mysql_query($query) ;
}
This code is for searching my database with multiple keywords, but it only can enter one key word at a time for searching, if enter 2 keywords it will return no results. Anyone here can tell me how to solve this problem?