Column names into variables
| From: | z | Date: | Wed, 26 Jul 2006 17:14:52 +0000 |
| Subject: | Column names into variables | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-42261@lists.php.net to get a copy of this message | ||
Hi,
I have a table with about 50 columns in it. I'd like to query the
information for one record, and hold the data in variables that have the
same name as the column headings, along these lines:
$query = "Select * from
postings where id = $userid";
$result = mysql_query($query);
while($row=mysql_fetch_array($result)) {
$id = $row["id"];
$location = $row["location"];
$employer = $row["employer"];
...
}
I'd like to do this for all columns in the table, and feel like there's a
way to do this automatically, but haven't been able to find the function or
syntax to use. Any help is greatly appreciated.
Thanks,
Zeth