RE: [PHP-DB] Using a loop on a result destroys array??
| From: | Norland, Martin | Date: | Wed, 24 Nov 2004 15:24:34 +0000 |
| Subject: | RE: [PHP-DB] Using a loop on a result destroys array?? | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-37400@lists.php.net to get a copy of this message | ||
-----Original Message-----
From: Mark Benson [mailto:markbenson@mac.com]
>The real problem you're having is the statement says "while there are
>results in this query, grab them" - once you reach the end of the first
>while loop, there are no more results, so the second one is skipped
>right over - it's condition *never* evaluates true.
So by running a "while (mysql_fetch_array($result)" loop over a fetch
array you effectively empty it?
<snip>
Well, not really - although in the end, yes, it will be 'empty' -
mysql_fetch_array actually fetches a single row (the next one, if
available) returned from the mysql query into an associative array.
You're being handed the data from mysql, one row at a time as requested,
and sticking it into an array. $result is actually the resource id that
you give mysql so it knows what query to give you the information back
from.
- Martin Norland, Database / Web Developer, International Outreach x3257
The opinion(s) contained within this email do not necessarily represent
those of St. Jude Children's Research Hospital.