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:[EMAIL PROTECTED]]
Sent: Tuesday, September 04, 2001 3:30 PM
To: [EMAIL PROTECTED]
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to