RE: [PHP] Getting Query Results Row Number during a While Loop

From: Date: Wed, 22 Dec 2004 18:34:31 +0000
Subject: RE: [PHP] Getting Query Results Row Number during a While Loop
Groups: php.general 
Request: Send a blank email to php-general+get-204980@lists.php.net to get a copy of this message
[snip] I am creating a query and displaying the results during a while Loop. I know how to get the total number of rows but need to know which row I am currently working on in the loop. [/snip] You need a variable, like $i, to hold the number, then increment and display $i = 0; while(your database stuff happens){ $i++; echo $i . "\n"; } /* cleanup after the while loop is done */ unset($i);

« previous php.general (#204980) next »