Re: mysql and php
| From: | php3 at developersdesk dot com | Date: | Tue, 18 Jul 2000 01:27:27 +0000 |
| Subject: | Re: mysql and php | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-1222@lists.php.net to get a copy of this message | ||
Addressed to: Cody Caughlan <codyc@cisco.com>
php-db@lists.php.net
** Reply to note from Cody Caughlan <codyc@cisco.com> Mon, 17 Jul 2000 10:20:11 -0700
> If you wanted to use numbers as your fruits in the database, then
> create another array that corresponds to the first and put that array
> name in place of $vals array in the function.
Or do something like this...
$Values = array( '1' => 'Apple', '2' => 'Peach',
'3' = 'Orange' );
function SelectField( $Name, $Selected, $Values ) {
echo "<SELECT NAME=\"$Name\">\n";
while( list( $Index, $Value ) = each( $Values )) {
echo "<OPTION VALUE=\"$Index\"";
if($Selected == $Index ) echo " SELECTED";
echo ">$Value</OPTION>\n";
echo "</SELECT>\n";
}
The index values do not have to be numbers, for example you could use:
$Values = array( 'ID' => 'Idaho', 'UT' = 'Utah',
'MT' = 'Montana' );
Rick Widmer
Internet Marketing Specialists
www.developersdesk.com