I have a drop down list in my user registration page where people signing up choose what state they are from. The form looks like this:
<select name="state">
<option value="AL">Alabama
<option value="AK">Alaska
<option value="AZ">Arizona
<option value="AR">Arkansas
.
.
.
</select>
Later, when people want to update their member info, I want the drop down list to know where they are from and select the appropriate state. So it should look like this:
<select name="state">
<option value="AL" <? if ($state == "AL") echo "selected"; ?>>Alabama
<option value="AK" <? if ($state == "AK") echo "selected"; ?>>Alaska
<option value="AZ" <? if ($state == "AZ") echo "selected"; ?>>Arizona
<option value="AR" <? if ($state == "AR") echo "selected"; ?>>Arkansas
.
.
.
</select>
My question is, is there a better way to do this so I don't have over 50 if statements on my page? I'm wondering if this will really slow down the page.