I'm a little stumped here, maybe I haven't had enough coffee yet.......

Anyway, I have a lot of SQL queries that return one row if there is a match
and instead of having to write out something like this:

$firstname = $row["firstname"];
$lastname = $row["lastname"];
$midinitial = $row["midinitial"];
$preferredname = $row["preferredname"];
$address1 = $row["address1"];
$address2 = $row["address2"];
$city = $row["city"];
$state = $row["state"];
$zip = $row["zip"];

I thought I'd loop through the result and and get the info out like this:

$nrows = mysql_num_rows($result);
$nfields = mysql_num_fields($result);
$rowarray = mysql_fetch_row($result);

for ($i=0; $i<$nfields; $i++){
$fname = mysql_fieldname($result,$i);
$val = $rowarray[$i];
$fname = $val;

and then later in the page reference the values using <?=$address1?>

Problem is this isn't working. If I echo the varibles to the page they will
print out but they wont show up in the <?=$address1?> tags.

I tried setting the varibles to global and that still doesn't seem to work.
I know I'm missing something really simple and basic here. If someone could
give me a push in the right direction I'd appreciate it.



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]

Reply via email to