[PHP-DB] php/mySQL and html select

2001-05-06 Thread Nick Terzich

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=AKAK/option
option value=ALAL/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


__
Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices
http://auctions.yahoo.com/

-- 
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]




Re: [PHP-DB] php/mySQL and html select

2001-05-06 Thread Tom Carter

Hi Nick,

Assuming you have the rest of the databse interaction, all you need to is
store the value of the selection (the store script will recieve a varialbe
$state=AK or whatever.

To then display the users state do the following
//Get the users state from the database
//do this however appropiate in your code
$users_state = AK; //(for the sake of argument)

//create array of states (better way of making the form
$states = array(AK,AR,);

$numstates=count($states);
echo(select name=\state\);
for($i=0;$inumstates;$i++)
{
$currstate=$states[$i];
echo(option value=\$currstate\); //print first part of statement
//if this option is the users add the selected keywork
if($currstate==$users_state) echo( SELECTED);
echo( $currstate);//finish the tag
}
echo(/select);

Hope this helps!
Tom




 On Sun, 6 May 2001, Nick
Terzich wrote:

 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=AKAK/option
 option value=ALAL/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


 __
 Do You Yahoo!?
 Yahoo! Auctions - buy the things you want at great prices
 http://auctions.yahoo.com/

 --
 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]



-- 
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]