Re: Endless 'while' loops?
| From: | Leif K-Brooks | Date: | Thu, 30 Oct 2003 09:33:11 +0000 |
| Subject: | Re: Endless 'while' loops? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-168130@lists.php.net to get a copy of this message | ||
Dave G wrote:
In the example they give in this book, they use a "while" loop (page 670, for anyone who has it). But it's confusing because it looks like this: while ( $subscriber = mysql_fetch_row($result)) { [write and send the email] } $subscriber is probably an array, filled with the email address and information about the mailing list subscriber. But in the rest of the script I can't find where they declare and fill this array. But more than that, I can't understand how this "while" loop would ever stop running. Nothing seems to change $subscriber within the "while" loop's control structure. It doesn't ever say anything like "$subscriber ++1". Nor does $result have anything act upon it which would change it. So to me they both look static, and this loop looks endless. In PHP, the equal sign returns the value assigned. For instance, this will output 5 and set $foo to 5:print $foo = 5; Now, the mysql_fetch_row function returns an array of results, or false if it's gone through all the results (it automagically knows which result it's on). If it's the last row, $subscriber is set to false and false is given for the loop condition. -- The above message is encrypted with double rot13 encoding. Any unauthorized attempt to decrypt it will be prosecuted to the full extent of the law.