RE: [PHP] Multiple values in a form option field
| From: | Daryl Meese | Date: | Thu, 13 Nov 2003 20:45:41 +0000 |
| Subject: | RE: [PHP] Multiple values in a form option field | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-169568@lists.php.net to get a copy of this message | ||
Hello, See Below.
-----Original Message-----
From: Jeff McKeon [mailto:jmckeon@telaurus.com]
Sent: Thursday, November 13, 2003 2:05 PM
To: php-general@lists.php.net
Subject: [PHP] Multiple values in a form option field
I have a php page that has a web form on it.
I do a query to populate the options in a drop down box in the form.
[code]
<select size="1" name="customer">
<?PHP
while($query_data1=mysql_fetch_row($result1)){
echo"<option
value='$query_data1[0]'>$query_data1[1]</option>";
}
?>
[code]
$query_data1[0] is a userID number
$query_data1[1] is the user's Email address
So when the user selects an email addres from the drop down box, the
userID is stored and later writen to a database.
What I now need to do is store not only the userID but the email address
as well. Is there a way using a form to store 2 values using one drop
down box? So basically I want to store the userID and the Email address
to a variable in the form so that both may be written to different
fields in the database later.
Jeff
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
I sometimes build the value of the list option like this:
<option value="UserID~!~emailaddress">Email Address</option>
Then use the split function (split("~!~", $var)) to get the two (or more)
values without reliance on javascript.
Daryl