PDA

View Full Version : Numbering Rows in queries?



Lucky13
May 25th, 2001, 19:15
Hello...I'm trying to figure out how to number the rows of the results of a query...does anyone know how to do this?

I want it to look like this:

1. Name1
2. Name2
3. Name3

And so on. Thanks a lot!

~Lucky13

lucifer
May 25th, 2001, 19:23
$result=mysql_db_query($db,"select name from names");

$count=1;
while ($rows=mysql_fetch_array($result)){
echo "$count :" . $rows['name'] . "<br>";
$count++;
}



would do it if you are connected to the database $db

your SQL may be different - allows you to add more fields later

Lucky13
May 25th, 2001, 19:25
Awesome....thanks.