Hi,
I've got a free hyperbaric search database where people can look for a Dive chamber close to them. I'm in the process of making an update form where staff can login and update contact details held on our database.
When they login, a form opens with all of their details pre-entered into text feilds from the MySQL database. Easy enough. But I'm just having trouble working out how to pre-select the country using the value in the DB when the dropdown has around 200 hardcoded values.
Ok, I've done this before with a Gender and Title drop down, where it was easy to just do the following:
Obviously this approach may be a bit tedious with 200 values. Is there an easier way? Am I better off loading all my countries into a table and do a loop to find the selected value? I don't want to use a text feild here, as we want to control the country names that are displayed in the search listings.
Thanks for any help
Aaron
I've got a free hyperbaric search database where people can look for a Dive chamber close to them. I'm in the process of making an update form where staff can login and update contact details held on our database.
When they login, a form opens with all of their details pre-entered into text feilds from the MySQL database. Easy enough. But I'm just having trouble working out how to pre-select the country using the value in the DB when the dropdown has around 200 hardcoded values.
Ok, I've done this before with a Gender and Title drop down, where it was easy to just do the following:
Code:
<select name="title" id="title" >
<OPTION value=""> </option>
<OPTION value="Mr"<? if (isset($recordset['title']) and $recordset['title'] == 'Mr') echo 'selected'?>>Mr</option>
<OPTION value="Mrs"<? if (isset($recordset['title']) and $recordset['title'] == 'Mrs') echo 'selected'?>>Mrs</option>
<OPTION value="Miss"<? if (isset($recordset['title']) and $recordset['title'] == 'Miss') echo 'selected'?>>Miss</option>
<OPTION value="Ms"<? if (isset($recordset['title']) and $recordset['title'] == 'Ms') echo 'selected'?>>Ms</option>
<OPTION value="Dr"<? if (isset($recordset['title']) and $recordset['title'] == 'Dr') echo 'selected'?>>Dr</option>
</select>
Obviously this approach may be a bit tedious with 200 values. Is there an easier way? Am I better off loading all my countries into a table and do a loop to find the selected value? I don't want to use a text feild here, as we want to control the country names that are displayed in the search listings.
Thanks for any help
Aaron