Show drop menu

Links for php scripts

Moderators: egami, macek, gesf

Post Reply
New php-forum User
New php-forum User
Posts: 124
Joined: Sun Feb 29, 2004 6:26 am

Wed Sep 15, 2004 4:46 pm

i want to show number of drop menu according to table record, how? e.g if the table got 11 records, i want to show 11 drop menus at the same time, i know this have to use looping, but can u show me how to do it and also passing the each of the drop menu variable also, thanks

User avatar
Posts: 1716
Joined: Sun Dec 29, 2002 5:03 am
Location: Portugal / Sweden

Thu Sep 16, 2004 1:03 am

There's a lot of this in this forum :)

Code: Select all


$result = mysql_query("SELECT name, value FROM whatever");

print '<select name="options">';
   while($row = mysql_fetch_array($result)){
      print '<option value="' . $row['value'] . '">' . $row['name'] . '</option>' . "\n";
print '</select>';

Gonçalo "gesf" Fontoura

Post Reply