I am using a function to populate a select tag with
states/provinces/territories -
<?php function stateselectlist() {
$states = array('AL' => 'Alabama', 'AK' =>
'Alaska', 'AZ' => 'Arizona', 'AR' => 'Arkansas', 'CA'
=> 'California',
'CO' => 'Colorado', 'CT' => 'Connecticut', 'DC' =>
'District of
Columbia', 'DE' => 'Delaware', 'FL' => 'Florida', 'GA'
=> 'Georgia', 'HI'
=> 'Hawaii', 'ID' => 'Idaho', 'IL' => 'Illinois',
'IN' => 'Indiana', 'IA'
=> 'Iowa', 'KS' => 'Kansas', 'KY' => 'Kentucky',
'LA' => 'Louisiana',
'ME' => 'Maine', 'MD' => 'Maryland', 'MA' =>
'Massachusetts', 'MI' =>
'Michigan', 'MN' => 'Minnesota', 'MS' => 'Mississippi',
'MO' =>
'Missouri', 'MT' => 'Montana', 'NE' => 'Nebraska', 'NV'
=> 'Nevada', 'NH'
=> 'New Hampshire', 'NJ' => 'New Jersey', 'NM' =>
'New Mexico', 'NY' =>
'New York', 'NC' => 'North Carolina', 'ND' => 'North
Dakota', 'OH' =>
'Ohio', 'OK' => 'Oklahoma', 'OR' => 'Oregon', 'PA'
=> 'Pennsylvania', 'PR
'=> 'Puerto Rico', 'RI' => 'Rhode Island', 'SC' =>
'South Carolina', 'SD'
=> 'South Dakota', 'TN' => 'Tennessee', 'TX' =>
'Texas', 'UT' => 'Utah',
'VT' => 'Vermont', 'VA' => 'Virginia', 'WA' =>
'Washington', 'WV' =>
'West Virginia', 'WI' => 'Wisconsin', 'WY' =>
'Wyoming', 'ONT' =>
'Ontario',
'QUE' => 'Quebec', 'NOV' => 'Nova Scotia', 'NEW' =>
'New Brunsick',
'MAN' => 'Manitoba', 'BRI' => 'British Columbia', 'PEI'
=> 'Prince Edward
Island',
'SAS' => 'Saskatchewan', 'ALB' => 'Alberta', 'NFL'
=> 'Newfoundland and
Labrador',
'NWT' => 'Northwest Territories', 'YUK' => 'Yukon',
'NUN' => 'Nunavut');
$str = "<select name=\"VisitorBillStateID\"
id=\"VisitorBillStateID\">\n";
foreach ($states as $key => $value) {
if($key == 'AL') { $str .= "<optgroup
label=\"States\">"; }
if($key == 'ONT') { $str .= "<optgroup
label=\"Provinces\">"; }
if($key == 'NWT') { $str .= "<optgroup
label=\"Territories\">"; }
$str .= "<option value=\"$key\"";
if ($row_rsAccount['VisitorBillStateID'] == $key) {
$str .= " selected=\"selected\"";
}
$str .= ">$value</option>\n";
}
$str .= "</select>\n";
return $str;
} // END function stateselectlist
//echo $row_rsAccount['VisitorBillStateID']; exit();
echo stateselectlist();
This is being used on an "account" form page.
When the page loads the user has already logged in and the
recordset has
been picked based on a session variable's value.
If I uncomment that next-to-last echo, I get the correct
state printed to
the page for the value of
$row_rsAccount['VisitorBillStateID'].
If I comment it out, and allow the function to be called, I
get oodles of
instances of -
Notice: Undefined variable: row_rsAccount in
/vservers/squarewheeli/htdocs/s_account.php on line 268
Line 268 is this line -
if ($row_rsAccount['VisitorBillStateID'] == $key) {
What, please, am I overlooking here?
Thanks,
--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.projectseven.com/go
- DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs,
Tutorials & Resources
==================