make keys of a associative array DB field names?
| From: | Bing Du | Date: | Fri, 14 Apr 2006 19:54:38 +0000 |
| Subject: | make keys of a associative array DB field names? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-234018@lists.php.net to get a copy of this message | ||
Hi,
Would anybody remind me how this should be achieved?
This returns all the names of the fields.
while( ($f = odbtp_fetch_field( $qry )) ) {
echo $f->name . "\n";
}
This returns the query results:
while( ($rec = odbtp_fetch_array($qry)) ) {
foreach ($rec as $var) {
echo "$var\n";
}
}
How should I connect them together? Say, the fields are 'name', 'age',
'score'. I want to print out $rec['name'], $rec['age'] and
$rec['score']
rather than using $rec[0], $rec[1] and $rec[2].
Thanks in advance for any ideas,
Bing