Re: Problem with a for loop...
| From: | 1LT John W. Holmes | Date: | Thu, 16 Jan 2003 13:51:26 +0000 |
| Subject: | Re: Problem with a for loop... | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-131855@lists.php.net to get a copy of this message | ||
Are you sure $n is being set somewhere?
Why not do it like this:
while($row = mysql_fetch_row($resultCurrName))
{
print $row[0]+1;
//do rest of whatever...
}
---John Holmes...
----- Original Message -----
From: "Davíð Örn Jóhannsson" <david@atom.is>
To: <php-general@lists.php.net>
Sent: Thursday, January 16, 2003 8:39 AM
Subject: [PHP] Problem with a for loop...
I have al for loop that looks something like this:
$checkCurrName = "SELECT imgName FROM $db_img ORDER BY imgName DESC";
$resultCurrName = mysql_query($checkCurrName, $db);
for ($i = 0; $i < $n; $i++){
list($currName) = mysql_fetch_row($resultCurrName);
$newName = $currName++;
print($newName);
//insert $newName into db
}
The problem is that I get the first printout right (the current value in
the database + 1) but all after that equal the first one, it looks
like i'm not getting the newest value from the database after the first
loop.
Any Ideas about this
Thanks, David