Hi All,
I have two select boxes that pull info from a database.
The thing im trying to do is get the second one to be dependant on what is chosen in the first one without having to refresh the page.
This is what i have so far.
echo" <select name=\"category\"> ";
$results= mysql_query("SELECT ID, country from airports group by country order by country",$connection);
$id = "ID";
$idname = "country";
echo mysql_error();
if (mysql_Numrows($results)>0)
{
$numrows=mysql_NumRows($results);
$x=0;
while ($x<$numrows){ //loop through the records
$theId=mysql_result($results,$x,$id);
$theName=mysql_result($results,$x,$idname);
echo "<option value=\"$theId\">$theName</option>\n";
$x++;
}
}
echo "</select>";
print "<br>\n";
print "<br>\n";
print "<br>\n";
echo" <select name=\"category2\"> ";
$results= mysql_query("SELECT ID, airport from airports where country='$category'",$connection);
$id = "ID";
$idname = "airport";
echo mysql_error();
if (mysql_Numrows($results)>0)
{
$numrows=mysql_NumRows($results);
$x=0;
while ($x<$numrows){ //loop through the records
$theId=mysql_result($results,$x,$id);
$theName=mysql_result($results,$x,$idname);
echo "<option value=\"$theId\">$theName</option>\n";
$x++;
}
}
echo "</select>";
The mere fact that im putting this here says that i can get it to work.!
Can anyone shed some light on how i might be able to do this?
Many thanx
Dave Faulkner