question
| From: | Robert Weeks | Date: | Wed, 12 Dec 2001 15:03:09 +0000 |
| Subject: | question | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-14959@lists.php.net to get a copy of this message | ||
Hi,
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.
Thanks,
Robert