return stored state in dropdown menu on user update page
Posted: Thu Jun 11, 2009 12:41 am
Hi, I have a user update page in PHP where the user can update their personal information. At registration and the update page, I use a dropdown menu for the state like so:
print '<td width="160"><p align="right">State</td>';
print '<td width="600"><p align="left"><select name="state">';
print '<option value="0" selected="selected">Select Your State</option>';
print '<option value="AL" selected_AL>Alabama</option>';
print '<option value="AS" selected_AS>American Samoa</option>';
print '<option value="AK" selected_AK>Alaska</option>';
I am able to return the data from the stored database fine, but the problem I am having is getting the dropdown menu to change to the retrieved state as it's selection. For example, Alabama would be stored in my database as AL. How do I make it so when AL is returned for the user from the stored info in the database, the dropdown menu is set for Alabama instead of "Select Your State"?
Thanks for any help with this PHP problem. It is appreciated.
print '<td width="160"><p align="right">State</td>';
print '<td width="600"><p align="left"><select name="state">';
print '<option value="0" selected="selected">Select Your State</option>';
print '<option value="AL" selected_AL>Alabama</option>';
print '<option value="AS" selected_AS>American Samoa</option>';
print '<option value="AK" selected_AK>Alaska</option>';
I am able to return the data from the stored database fine, but the problem I am having is getting the dropdown menu to change to the retrieved state as it's selection. For example, Alabama would be stored in my database as AL. How do I make it so when AL is returned for the user from the stored info in the database, the dropdown menu is set for Alabama instead of "Select Your State"?
Thanks for any help with this PHP problem. It is appreciated.