Reputation: 1974
I'm making a forum software, and I need to put an array into a drop down selection box. Like in the administration panel, have a drop down box that lists all of the current forums, so you choose one to delete or modify.
I can get the array fine, but how would I put that in a drop down box, or is there an alternative?
$select_forums = mysql_query("SELECT name FROM forums");
while ($row = mysql_fetch_array($select_forums, MYSQL_ASSOC)) {
printf (" Name: %s", $row["name"]);
}
Upvotes: 1
Views: 417
Reputation: 737
<select>
<?php while ($row = mysql_fetch_array($select_forums, MYSQL_ASSOC)) { ?>
<option value="<?php echo $row["id"] ?>"><?php echo $row["name"] ?></option>
<?php }?>
</select>
Upvotes: 2