Link to home
Start Free TrialLog in
Avatar of justmelat
justmelat

asked on

Populate a combo/drop box with mySql data

I have a drop box on one of my php forms.  How do I populate that combo box with the selected column from my database.  Say I have a tbl of names and addresses and I want one of my drop boxes to display all the names so my user can select one or two of them - how can I accomplish that?  Another wrinkle - when I open this form (which will pull the data for a specific record), I want the combo box to display the name of the person associated with that record.  I currently have some of the names hardcoded into the form and as you know, it will refresh each time the php page is opened and just display the first name in the list.  Help :)
ASKER CERTIFIED SOLUTION
Avatar of snoyes_jw
snoyes_jw
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of justmelat
justmelat

ASKER

You are great, that worked perfectly.  For others looking at this posting, be sure to maintain the space that is before the selected in this line:

echo " selected";

I took it out by mistake and it took forever to figure out what was wrong.

Thanks alot snoyes_jw for your help.