(side note....this is a seperate file i called functions.php)
Code: Select all
<?php
function getStateCode()
{
$stateCode = array(1=> "AL",
"AK",
"AZ",
"AR",
"CA",
"CO",
"CT",
"DE",
"...",
"WY");
return $stateCode;
}
function getStateName()
{
$stateName = array(1=> "Alabama",
"ALASKA",
"ARIZONA",
"ARKANSAS",
"CALIFORNIA",
"COLORADO",
"CONNECTICUT",
"DELAWARE",
"...",
"WYOMING");
return $stateName;
}
?>in another file i put
Code: Select all
if($field == "state")
{
echo "<tr><td style=\"text-align:right;
font-weight:bold\">State</td>
<td><select name='state'>";
$stateName=getStateName();
$stateCode=getStateCode();
for ($n=1;n<=50;$n++)
{
$state=$stateName[$n];
$scode=$stateCode[$n];
echo "<option value='$scode'";
if($scode== @$_POST['state'])
echo " selected";
echo ">$state\n";
}
echo "</select>";
}and here is the array for my form
Code: Select all
$fields_2 = array( "user_name" => "User Name",
"password" => "Password",
"email" => "Email Address",
"first_name" => "First Name",
"last_name" => "Last Name",
"street" => "Street",
"city" => "City",
"state" => "State",
"zip" => "Zip",
"phone" => "Phone",
"Fax" => "Fax",
);Code: Select all
"state" => "State",