I have seen the following while loop condition in many examples and even I have used it in many times. I know how it works and how to use it. But as i code the condition here doesn’t make any sense.
As I see the code, the condition is like it’s always true. Just like while(1). Because to the *mysql_fetch_assoc()*, the same data is passed is passed all the time. So the condition is a constant.
while($arr = mysql_fetch_assoc($data))
{
//other code
}
Now, where Am I Wrong ????
Each call to
mysql_fetch_assocgets the next row from the result set. If there is no row anymore it returnsfalseand the loop terminates.$datais a resource data type and will probably keep the state about which row was fetched last.This is not so unusual, even arrays have an internal pointer to the current element which can be manipulated using certain array functions.