RE: [PHP] $i vs. $r
| From: | Jay Blanchard | Date: | Mon, 27 Mar 2006 21:50:47 +0000 |
| Subject: | RE: [PHP] $i vs. $r | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-232675@lists.php.net to get a copy of this message | ||
[snip]
Does anyone have a clue why using this code doesn't work:
$i = 0;
while ($row = mysql_fetch_array($result))
{
echo ("Blah blah blah");
$i++;
}
but this code does?
$r = 0;
while ($row = mysql_fetch_array($result))
{
echo ("Blah blah blah");
$r++;
}
I don't use $i anywhere else on the page.
[/snip]
While $i is often used as an iterative (hence $i) variable it is not
required to be $i. You are echoing $r at the end of the while loop,
aren't you? Nothing in the loop requires an $i at this point.