Re: Get row number from mysql

From: Date: Thu, 14 Mar 2002 06:10:26 +0000
Subject: Re: Get row number from mysql
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-88451@lists.php.net to get a copy of this message
In article <000701c1cb06$3b54f3b0$0101a8c0@nightengale>, tyler@captainjack.com says... > 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 > > Given that the data is not stored in the table in any particular order (that is likely to be useful to you), perhaps you could add another field which has a value allocated by you that you can use for your purpose. -- David Robley Temporary Kiwi! Quod subigo farinam

« previous php.general (#88451) next »