Let’s say I have an HTML dropdown menu as,
<p>General Medical History:
<select name="otherproblem">
<option value="Nothing">Nothing</option>
<option value="Allergy: Penicillin">Allergy: Penicillin</option>
<option value="Aspirin">Aspirin</option>
<option value="Erythromycin">Erythromycin</option>
<option value="Latex or Rubber Products">Latex or Rubber Products</option>
<option value="Codeine">Codeine</option>
<option value="Tetracycline">Tetracycline</option>
<option value="Germicides/Pesticides, Foods">Germicides/Pesticides, Foods</option>
<option value="Other">Other</option>
<option value="Asthma">Asthma</option>
<option value="Bleeding Disorders">Bleeding Disorders</option>
<option value="Diabetes">Diabetes</option>
<option value="Epilepsy">Epilepsy</option>
<option value="GI disorders">GI disorders</option>
<option value="Heart disease">Heart disease</option>
<option value="Hepatitis">Hepatitis</option>
<option value="Jaundice">Jaundice</option>
<option value="Liver disease">Liver disease</option>
<option value="Neoplasm">Neoplasm</option>
<option value="Psychiatric Problems">Psychiatric Problems</option>
<option value="Respiratory diseases">Respiratory diseases</option>
<option value="Rheumatic fever">Rheumatic fever</option>
</select>
</p>
By selecting one of the options, I am adding the particular value to the database as a VARCHAR.
Now I am calling them back, let’s say, for an edit, so I need the entered data back to the same form, where I could retrieve all the other things to text boxes. But I have no idea how to get the value from the db and make it selected in this dropdown list. All I could do is saving the retrieved value from db to a variable named, $otherproblem
You have two options, one is to load the list along the lines of:
Dirty, but it will work with the way you have it setup currently. You can also rig it by simply making the item select at the top of the list, and then the full list like this:
There is much neater ways to do this, but without seeing how you are pulling the data, these two options will work in any case.