For Programmers: Free Programming Magazines  


Home > Archive > PHP DB > November 2004 > RE: [PHP-DB] Using a loop on a result destroys array??









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author RE: [PHP-DB] Using a loop on a result destroys array??
Martin Norland

2004-11-24, 3:56 pm

-----Original Message-----
From: Mark Benson [mailto:markbenson@mac.com]=20

>The real problem you're having is the statement says "while there are=20
>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=20
>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.
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com