Jump to content

Populate Dropdown with database values


tet3828

Recommended Posts

Im looking to populate a drop down menu with whatever value maybe in a column of my SQL database.
example:

in my 'products' database  itemCat (item catagory) maybe Holiday, Beauty, Cosmetic,ect.

How would I make each of these values show in my dropdown box?

or would it be better to use radio boxes?
Link to comment
https://forums.phpfreaks.com/topic/26311-populate-dropdown-with-database-values/
Share on other sites

[code]<?php
php require("config.php");
$result = mysql_query("SELECT * FROM spell");
?>

<select name="wordlist">
<option value="1" selected>Select Word</option>

<?php
  while($row = mysql_fetch_array($result)){
      echo "<option value=\"$row['words']\">$row['words']</option>\n";
  }
?>[/code]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.