Re: Re: Get row number from mysql

From: Date: Thu, 14 Mar 2002 04:02:19 +0000
Subject: Re: Re: Get row number from mysql
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-88429@lists.php.net to get a copy of this message
hmmm, I never thought of that. Thanks for the help. ;-) Tyler ----- Original Message ----- From: "michael kimsal" <michael@tapinternet.com> To: <php-general@lists.php.net>; "Tyler Longren" <tyler@captainjack.com> Cc: "PHP-General" <php-general@lists.php.net> Sent: Wednesday, March 13, 2002 9:57 PM Subject: [PHP] Re: Get row number from mysql > Tyler Longren wrote: > > Hello, > > > > How can I get the number of the current row, something like this: > > > > <? > > $sql = mysql_query("SELECT * FROM table ORDER BY id DESC"); > > while ($row = mysql_fetch_array($sql)) { > > $id = $row["id"]; > > $name = $row["name"]; > > print "$current_row_number. $name<Br>"; > > } > > ?> > > I can't just use the id field, because the ID's might not always be 1, 2, 3, > > 4, 5, 6, etc...they could go 1, 2, 4, 5, 8. > > > > I need it to look like this: > > 1. first person > > 2. second person > > 3. third person > > > > and so on and so forth. > > > > Can anyone advise me on how I should do this? > > > > thanks, > > Tyler > > > > > > > > Why not just put a counter in there? > > while ($row = mysql_fetch_array($sql)) { > ++$counter; > $id = $row["id"]; > $name = $row["name"]; > print "$counter. $name<Br>"; > } > > > > Michael Kimsal > http://www.phphelpdesk.com > PHP support when you need it > 734-480-9961 > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >

« previous php.general (#88429) next »