Re: Shortcut for MySQL $variable = $row["variable"];?
| From: | David Robley | Date: | Fri, 06 Oct 2000 02:26:19 +0000 |
| Subject: | Re: Shortcut for MySQL $variable = $row["variable"];? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-18820@lists.php.net to get a copy of this message | ||
On Fri, 06 Oct 2000, Erica Douglass wrote:
> Hello,
>
> Is there any kind of loop structure to tell PHP to make a variable for
> every row item returned from MySQL, instead of having to do this:
>
> while ($row = mysql_fetch_array ($result)) {
> $variable = $row["variable"];
> $variable2 = $row["variable2"];
> # etc, etc, for EVERY item...
> };
>
> I'd rather not make constants by using define().
>
> Erica
PHP can do _anything_! You want extract
while ($row = mysql_fetch_array ($result)) {
extract($row);
and now all the field names are available as variables.
--
David Robley | WEBMASTER & Mail List Admin
RESEARCH CENTRE FOR INJURY STUDIES | http://www.nisu.flinders.edu.au/
AusEinet | http://auseinet.flinders.edu.au/
Flinders University, ADELAIDE, SOUTH AUSTRALIA