Combining Radio button, drop down menu and search box
Ok…here is the site: http://www.halfwayenterprises.com/search/tyrell.htm
What am trying to do is this…enable users to search 2 ways, but first they have to choose if they want to search documents whose status are current, obsolete, or both. Then they can search by category and subcategory. Finally they can search current, obsolete, or both by search term in documents title, point of contact or purpose. To my surprise everything works ok…until I try to use the search box with the status of “all” aka “both”. Here is the html part...
function redirect(x){
for (m=temp.options.length-1;m>0;m--)
temp.options[m]=null
for (i=0;i<group[x].length;i++){
temp.options[i]=new Option(group[x][i].text,group[x][i].value)
}
temp.options[0].selected=true
}
function go(){
location=temp.options[temp.selectedIndex].value
}
//-->
</script>
$res = mysql_query("SELECT * FROM material WHERE status='$status' AND category='$category' AND subcategory='$subcategory' ORDER BY `documentid` ASC ");
//This is only displayed if they have submitted the form
if ($searching =="yes")
{
echo "<h2>Results</h2><p>";
//If they did not enter a search term we give them an error
if ($find == "")
{
echo "<p>You forgot to enter a search term";
exit;
}
// We preform a bit of filtering
$find = strtoupper($find);
$find = strip_tags($find);
$find = trim ($find);
//Now we search for our search term, in the field the user specified
$data = mysql_query("SELECT * FROM material WHERE status1='both' AND lower($field) LIKE'%$find%' LIMIT 0,30");
//And we display the results
while($row = mysql_fetch_array( $data ))
{
echo $row ['documentid'].' - '.$row['category'].' - '.$row['title'].' - '.$row['status'];
echo "<br>";
echo "<br>";
}
//This counts the number or results - and if there wasn't any it gives them a little message explaining that
$anymatches=mysql_num_rows($data);
if ($anymatches == 0)
{
echo "Sorry, but we can not find an entry to match your query<br><br>";
}
//And we remind them what they searched for
echo "<b>Searched For:</b> " .$find;
}
?>
<a href="tyrell.htm"> Return</a>
Any suggestions? I am stumped and overwhelmed...lol
Bookmarks