Hi,
I have 2 drop down lists, and I want the 2nd drop down list to be generated off the first drop down list selection . But I'm missing something on how to pass the variable of the first drop down list that the user selects to the second drop down list.
Any help appreciated
Here is the code.
if (!isset($HTTP_POST_VARS[submit])) {
/ User has not submitted form data /
echo "<table width=\"100%\" border=\"1\" cellspacing=\"2\" cellpadding=\"2\"><tr><td>";
// Creates the first dropdown list
echo "<form action=\"$PHP_SELF\" method=\"POST\"><select name=\'city_id[]\'><option value=\"\" \"selected\">Choose City</option>";
while ($row = mysql_fetch_array($query))
{
echo "<option value=\"{$row['city_id']}\">{$row['cities']}</option>";
}
echo "</select>";
echo "<input type=\"submit\" name=\"submit\" value=\"Go\"></form>";
} else {
// This could be completly wrong I'm a novice
$sql = "select * from provinces where city_id={$_POST['city_id']} order by provincename";
$query2 = mysql_query($sql);
// Creates second dropdown list with the provinces
echo "<form action=\"$PHP_SELF\" method=\"POST\"><select name=\"province name\"><option value=\"\" \"selected\">Chosse Province</option>";
while ($row = mysql_fetch_array($query2))
{
echo "<option value=\"{$row['pro_id']}\">{$row['provincename']}</option>";
}
echo "</select>";
echo "<input type=\"submit\" name=\"submit\" value=\"Go\"></form>";
}
echo "</table></tr></td>";
?>