RE: [PHP] Assign multiple variables from mysql_fetch_row() call

From: Date: Tue, 04 Sep 2001 21:40:37 +0000
Subject: RE: [PHP] Assign multiple variables from mysql_fetch_row() call
Groups: php.general 
Request: Send a blank email to php-general+get-65953@lists.php.net to get a copy of this message
You can use a while loop. Ie: (where $row is the result of a sql query) if ($row = mysql_fetch_array($result)) { do { $var1 = $row["column1"]; $var2 = $row["column2"]; $var2 = $row["column3"]; } while ($row = mysql_fetch_array($result)); } Johan Which World? PongWorld www.pongworld.com -----Original Message----- From: Egan [mailto:egan@sevenkings.net] Sent: Tuesday, September 04, 2001 3:30 PM To: php-general@lists.php.net Subject: [PHP] Assign multiple variables from mysql_fetch_row() call In perl I can say something like: ($var1, $var2) = $sqh->fetchrow_array() to assign column values to more than one variable at a time. So I tried similar syntax with PHP: ($var1, $var2) = mysql_fetch_row($sqh); but could not seem to work it out. I know you can do this with a temporary array, and then take values out of the array. But it would be nice to omit the temporary array. Is it possible? Egan -- 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

« previous php.general (#65953) next »