shinjuo
shinjuo

Reputation: 21042

How to fill a drop down menu

I want to populate a drop down menu with a column from a MySQL database. I have the rest of my database set up, but at the moment it is just a text entry box and it would be easier just to select the actually entry from a list. Also does anyone know of a good tutorial or site that has tutorials and example codes for PHP and MySQL

Upvotes: 0

Views: 1111

Answers (1)

Amy B
Amy B

Reputation: 17977

$result = // from the database

echo '<select name="foobars">';

while ($row = mysql_fetch_assoc($result))
{
   echo '<option value="'.$row['id'].'">'.$row['name'].'</option>';
}

echo '</select>';

Upvotes: 1

Related Questions