I've got a search engine on a page and I want the user to beable to narrow the search.
I've used this to allow users to chooses a category (and this bit works):
// Loop and echo category list from $sql1
?> <body bgcolor="#6699CC">
<form name="search" method="post" action="search.php" >
<select size=1 name="catlist">
<option SELECTED value="">Choose a category
<option value="">-------------<?php
while($row=mysql_fetch_array($result1)){
$cid = $row["cid"];
$category = $row["category"];
$category = stripslashes($category);
$category=ucwords($category);
echo("<OPTION VALUE='$cid'>$category\n");
}?></select>
The search engine in here
Then I've put this bit in to check the category:
If (($catlist)!="Choose a category") {$sql .=" and c.cid = $cid order by hit-1" . $limit;
}else{$sql .= " order by hit-1" . $limit;}
echo "$sql";
$result=mysql_query($sql) or die("Problem with query: ".mysql_error());
}
However, the result is always for a query with the last category in the list. Any ideas anyone?
All help appreciated