View Single Post
Old 08-30-2009, 06:13 PM   #2 (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

As you know, while loops will execute as long as a condition is true. The first one says while you can assign $row from mysql_fetch_assoc it can continue. When an array reaches its end you will not be able to assign it, making the while loop end. Mysql_fetch_assoc returns an array, so you can apply foreach to $row.

The syntax of foreach is
foreach($arr as $key => $value)

So the following code represents the values.
PHP Code:
$arr["key1"]  = 7//$key=key1 $value = 7
$arr["key2"] = 15//$key=key2 $value = 15
$arr["ABC"] = 23//$key=ABC $value = 23 
__________________

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