Re: Splitting Vars from MySQL in PHP
| From: | Philip Olson | Date: | Fri, 29 Apr 2005 23:36:01 +0000 |
| Subject: | Re: Splitting Vars from MySQL in PHP | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-214251@lists.php.net to get a copy of this message | ||
> > I remember in Perl I used to extract vars from a single fetchrow by adding
> > each var name to the beginning (like this). Only this ain'ta workin :)...
> > Anyone know the right syntax to do this?
> >
> > ($var1, $var2, $var3)= mysql_fetch_array($result, MYSQL_ASSOC)
>
>
> list($var1, $var2, $var3) = mysql_fetch_array($result, MYSQL_ASSOC);
> http://us4.php.net/manual/en/function.list.php
But remember that list() only works with numerical
arrays so use MYSQL_NUM (or array_values()) in the
above. For associative, extract() can be useful.
Regards,
Philip