08-30-2009, 06:13 PM
|
#2 (permalink)
|
|
Wizard
Join Date: Sep 2007
Posts: 1,299
Thanks: 17
|
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
|
|
|
|