Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Populate HTML Form Dropdown from DB 1

Status
Not open for further replies.

WilliamMute

Programmer
Jan 4, 2006
117
Hi all,

Can anyone please help towards how I can populate an HTML dropdown option list with values from a table column in my MYSQL DB using PHP please.

Any help appreciated.

Thank you
 
something like this

Code:
//run the query
$result = mysql_query("Select description, value from table");
//start the select box
echo '<select name="select">';
while ($row=mysql_fetch_assoc($result)){
//iterate through outputting options
echo '<option value="'.$row['value'].'">'.$row['description'].'</option>';
}
//close the select box
echo '</select>';
 
Simply Genius. Thanks once again jpadie. Works perfect. I have been getting a full page coding from different website I've been visit, so complex its unbeleivable and yours is just a few lines of straight forward codes.

'Simply the best'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top