Re: Shortcut for MySQL $variable = $row["variable"];?
| From: | Nick Talbott | Date: | Fri, 06 Oct 2000 07:24:55 +0000 |
| Subject: | Re: Shortcut for MySQL $variable = $row["variable"];? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-18841@lists.php.net to get a copy of this message | ||
>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...
>};
>
As an alternative to extract($result), which may not give the variable names
you want, you can also use
list($var1, $var2, ...) = mysql_fetch_array($result) ;
HTH
Nick Talbott
IT Policy and Strategy Manager, Powys County Council, UK
email nickt@powys.gov.uk
FAX +44 (0) 1597 824781
web http://www.powys.gov.uk and http://www.powysweb.co.uk