I have a series of three List Boxes, The first box is loading properly, however; the second and the third are loading but not filtering based on the previous selection. The tables are as such;
tblRestaurants
RestID
RestName
tblLocations
LocationID
RestID
CityID
AreaID
tblCities
CityID
CityName
tblAreas
AreaID
AreaName
I am using a function as well:
function createoptions($table , $id , $field , $condition_field , $value)
{
$sql = sprintf("select * from $table WHERE $condition_field=%d ORDER BY $field" , $value);
$res = mysql_query($sql) or die(mysql_error());
if (mysql_num_rows($res) > 0) {
while ($a = mysql_fetch_assoc($res))
$out[] = "{optionValue: {$a[$id]}, optionDisplay: '$a[$field]'}";
return "[" . implode("," , $out) . "]";
} else
return "[{optionValue: -1 , optionDisplay: 'No result'}]";
}
if (isset($_GET['tblRestaurants'])) {
echo createoptions("tblLocations" , "CityID" , "Street" , "RestID" , $_GET['tblRestaurants']);
}
if (isset($_GET['AreaBox'])) {
echo createoptions("tblAreas" , "AreaID" , "AreaName" , "AreaID = tblLocations.AreaID" , $_GET['tblLocations']);
}
die();
And this is to build the three Listboxes:
<form method = " post=">
<br mode=" hold=" />
<select name = " restname=" id=" restid=">
<br mode=" -1=">--Select--</option>
<br mode=" tblrestaurants=", " cityid="><br mode=" tbllocations=", " areaid="><br mode=">