Page 1 of 1

dropdown menu hepl

Posted: Wed May 10, 2006 7:15 pm
by saranda
in mysql i have a table called cars thet have two fields name and Id

what i want is in my page to have two dropdown menus and when i select a car in first dropdown menu in the
second dropdown menu to opear the id of the selected car

i have tryed in somany ways but nothing so i hope you can help ....

thnx.

Posted: Wed May 10, 2006 8:51 pm
by neophyte
Can you post the code you are currently using?

Posted: Wed May 10, 2006 11:43 pm
by Burrito
page 1:

Code: Select all

echo "<select name=\"carMake\" onChange=\"this.form.submit()\">
         <option value=\"1\">Ford</option>
         <option value=\"2\">Honda</option>";
page 2:

Code: Select all

$result = mysql_query("select `models` from `cars` where `makeId` = {$_POST['carMake']}");
echo "<select name=\"carModel\">";
while($row = mysql_fetch_assoc($result))
{
     echo <option value=\"{$row['models']}\">{$row['models']}</option>";
}
echo "</select>";