-----Original Message-----
From: Davíð Örn Jóhannsson [mailto:[EMAIL PROTECTED]] 
Sent: 16. janúar 2003 13:59
To: '1LT John W. Holmes'
Subject: RE: [PHP] Problem with a for loop...

I only want the last inserted row in the mysql database, and each time
the script goes trough the loop it adds a new row into the database, so
I want to get the newest row from the database when the script goes
throug the loop
The second time. But it dosent look like im geting the new row from the
database even though it is inserted. I'm wondering if mysql_querys don't
work in loops in order to get the newst row but if it works how would I
be able to accomplis that?

-----Original Message-----
From: 1LT John W. Holmes [mailto:[EMAIL PROTECTED]] 
Sent: 16. janúar 2003 13:51
To: Davíð Örn Jóhannsson; [EMAIL PROTECTED]
Subject: Re: [PHP] Problem with a for loop...

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" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
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


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to