Hello Nick,
> hi...
>
> I have a user registration system that I need to add a
> "state" field to. Part of the form will look something
> like this but with all 50 states instead of just two:
>
> <form>
> <select name="state">
> <option value="AK">AK</option>
> <option value="AL">AL</option>
> </select>
> </form>
>
> ...how do I insert the user's state into the database
> and then how do I show the user's state as the
> "selected" state in the drop down list later when the
> user comes back to update his/her profile?
>
> hope this makes sense.. thanks,
>
> nick
you have to build the <option> tags in PHP such as:
$states = array("AK" => "AK", "AL" =>"AL", ...);
while (list($key, $state) = each($states)) // iterates over $states array
{
printf("<option value='%s' %s>%s</option>", $key, ($key ==
$user_state?'selected':''), $state);
//user_state equals to the key of state currently printed out then append
'selected' attribute to the option tag
}
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]