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 开发者_如何学Pythona list. Also does anyone know of a good tutorial or site that has tutorials and example codes for PHP and MySQL
$result = // from the database
echo '<select name="foobars">';
while ($row = mysql_fetch_assoc($result))
{
echo '<option value="'.$row['id'].'">'.$row['name'].'</option>';
}
echo '</select>';
精彩评论