View Single Post
Old 08-31-2009, 01:55 PM   #5 (permalink)
Village Idiot
Wizard
Top Contributor 
 
Village Idiot's Avatar
 
Join Date: Sep 2007
Posts: 1,299
Thanks: 17
Village Idiot is on a distinguished road
Default

Quote:
Originally Posted by Dave View Post
Thanks, VI...

That helps...I'm still trying to get the full hang of this concept.

while($row = mysql_fetch_assoc($result))
{...

...means

1. The variable $row will be assigned the value(s) of the array of the first row of the results of the db query (assuming the query was successful).

2. Do everything within the WHILE loop. Drop the pointer to the second row in the db query results.

3. If there is another row in the db query results, then $row will take the second row's array value and repeat the WHILE loop.

4. And on and on, until the pointer is passed the last row of the db query resultset, at which point $row will not contain a value, and the WHILE loop exits.

Does that sound about right for the WHILE loop statement?

Thanks again,

Dave
1 and 2. Mysql_fetch_assoc returns a single row returned from the query as an array. It can keep track of itself and keep submitting the next row every time its called.

3. Yes, but not in your script since it returns before the loop can repeat.

4. Almost, I believe that the results are passed by value. But other that that, you are correct.
__________________

Village Idiot is offline  
Reply With Quote
The Following User Says Thank You to Village Idiot For This Useful Post:
Dave (09-02-2009)