Hello every,
I'm sorry if this question is trivial, but I'm a newbie both in programming and PHP, so where goes.
From what I understand through reading, while loops work as follows:
Where the statements within the enclosed while loop is continually evaluated until the expression returns false. So, how does the following code work?
Code: Select all
$result = mysql_query("SELECT id, name FROM mytable");
while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
printf("ID: %s Name: %s", $row[0], $row[1]);
}
Isn't $row = mysql_fetch_array(...) an assignment expression which always returns true when the assignment is successful? I'm getting confused here. So, if the expression evaluates true on the first run, then how can this while loop successfully list through the array in question? I've tried it and it worked beautifully, but am just wondering how it all works. Can someone shine some light on this subject? Much appreciated.
Cheers