I tweaked a search script I found months ago, and am now getting back around to fixing it...
I need some help debugging it...
if(isset($_GET['search']))
{
$search = $_GET['search'];
}
$search = trim($search);
$search = preg_replace('/\s+/', ' ', $search);
$keywords = explode(" ", $search);
$keywords = array_diff($keywords, array(""));
if ($search == NULL or $search == '%'){
} else {
for ($i=0; $i<count($keywords); $i++) {
$query = "SELECT * FROM research WHERE research.keywords LIKE '%".$keywords[$i]."%' OR research.products LIKE '%".$products[$i]."%'";
}
$result = mysql_query($query) or die(mysql_error());
}
if ($search == NULL or $search == '%'){
} else {
$count = mysql_num_rows($result);
}
If I remove the 'OR ETC.' statement, It returns only the keywords. That's great, but I need it to return either keywords or products in the DB...
thanks ahead of time,
Ted