dropdown menu hepl

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
saranda
Forum Newbie
Posts: 15
Joined: Wed May 10, 2006 6:18 pm

dropdown menu hepl

Post 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.
User avatar
neophyte
DevNet Resident
Posts: 1537
Joined: Tue Jan 20, 2004 4:58 pm
Location: Minnesota

Post by neophyte »

Can you post the code you are currently using?
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post 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>";
Post Reply