I have a select box that I'm trying to use to search for existing records in a database. Here is my select.
<?
$db = mysql_select_db("$DBName",$Link);
echo" <select name=\"KeyANumber\"> "; //start the select box
$results= mysql_query("SELECT DISTINCT ANumber from activitytracking Order by ANumber asc");
$id = "ANumber";
$idname = "ANumber";
echo mysql_error();
if (mysql_Numrows($results)>0) //if there are records in the fields
{
$numrows=mysql_NumRows($results); //count them
$x=0;
while ($x<$numrows){ //loop through the records
$theId=mysql_result($results,$x,$id); //place each record in the variable everytime we loop
$theName=mysql_result($results,$x,$idname);
echo "<option value=\"$theName\">$theName</option>\n"; //and place it in the select
$x++;
}
}
echo "</select>";
?>
And here is the sql of the resulting search when I click the submit button.
if (!$CommID) {
// print the list if we are not editing
$result = mysql_query("SELECT * FROM activitytracking WHERE ANumber Like '%".$_POST[KeyANumber]."%'
ORDER BY DateOfService",$db);
Everything works just fine when I'm using a simple input box that I can key into. But why doesn't this work with a select list box? I just get a blank page.