I want to set an "initially selected" option for a drop down list to be the same as the data in a field from a database query. For example:
If I query the database and the value returned for the "fruit" field is "apples", then I want to write a drop down menu like this:
So that you can see from the drop down what value is in the database, and change it if you want.
Any ideas?
Thanks.
Code:
<select name="fruit" id="fruit">
<option value="apples">apples</option>
<option value="pears">pears</option>
</select>
If I query the database and the value returned for the "fruit" field is "apples", then I want to write a drop down menu like this:
Code:
<select name="fruit" id="fruit">
<option value="apples" selected>apples</option>
<option value="pears">pears</option>
</select>
So that you can see from the drop down what value is in the database, and change it if you want.
Any ideas?
Thanks.