I have read tutorials about how to populate an entire Drop down list with MySQL, but the problem I am running into is that I only want to grab the one from the database and have that be the selected one. So I would have like a drop down with three items (Item1, Item2, Item3) in the database its stored in a column called itemschoice which has a value of ‘Item2’. How do I go about getting item2 to be selected when I load the drop down box?
Share
In your
<option>element add theselectedattribute for the value that is initemschoice.Crude example using a made up function to get the choice:
This is just an example, don’t copy & paste this without adding some kind of error verification!