Re: Shortcut for MySQL $variable = $row["variable"];?
| From: | Joe Stump | Date: | Fri, 06 Oct 2000 02:54:32 +0000 |
| Subject: | Re: Shortcut for MySQL $variable = $row["variable"];? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-18823@lists.php.net to get a copy of this message | ||
This is what I usually do:
while($row = mysql_fetch_array($result)){
while(list($key,$val) = each($row)){
$$key = $val;
}
// code here
// $row['firstname'] is now $firstname;
}
--Joe
On Thu, Oct 05, 2000 at 07:25:26PM -0700, 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 General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
/*****************************\
* Joe Stump *
* www.Care2.com *
* Office: 650.328.0198 *
* Extension: 122 *
\*****************************/
http://www.miester.org/Joe/Stump/Joe_Stump_resume.html
-----BEGIN GEEK CODE BLOCK-----
Version: 3.12
GB/E/IT d- s++:++ a? C++++ UL++$ P+ L+++$ E----! W+++$
N+@ o? K? w---! O-@ M+@ V-! P(++) PE(+) Y+@ PGP+++@ t+@
5? R-! tv@ b+ DI++@ D(++++) G++@ e+@ h@ r+! z(+++++**)!
------END GEEK CODE BLOCK------