Show drop menu

Links for php scripts

Moderators: macek, egami, gesf

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

Show drop menu

Postby kiwi » 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
gesf
Moderator
Moderator
Posts: 1717
Joined: Sun Dec 29, 2002 5:03 am
Location: Portugal / Sweden
Contact:

Postby gesf » Thu Sep 16, 2004 1:03 am

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

Code: Select all

<?php

$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>';

?>


Return to “PHP Scripts”

Who is online

Users browsing this forum: No registered users and 1 guest