PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
In your first code it says assign the return of mysql_fetch_array() (an array) to $row each loop iteration, and as long as $row doesn't equal false, keep looping. $row will not equal false until the loop after the last row is fetched from the result $testqry.
In your second example, you have fetched one row and assigned it to $test (an array). Then in your loop it says, assign $test to $row and as long as $row doesn't equal false, keep looping. Since $test equals an array return from the call to mysql_fetch_array() and you assign this each loop iteration to $row, then $row will never be false.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
A single "=" is like SAYING "A Now Equals B" but "==" is like ASKING "Does A now equal B". That's where the problem lies.
So, in the case of your while loop, you want to keep asking "$test" if there are more values. Once it returns false, then the loop will end.
this will not execute
because $row will never be equal to $test
but in the first loop
it is like while we can put array that we pull from the $test do instructions
example:
$test is like that:
[Record 1]----->array
[Record 2]
[Record 3]
[Record 4]
[Record 5]
the mysql_fetch_array parse each record to an array when it is out record it returns false
so $row will be equal to false which exit from the loop
I don't think the == is the problem. The issue is that every time you call mysql_fetch_array(), it gets the next result from the query. While ($row = mysql_fetch_array($query)) is like saying "If there's another result, get it".