View Full Version : Incrementing fetch_array()

11-25-2011, 12:40 AM

I want to display a table with data from the database which will show for example User and Rank.

I use 'mysql_fetch_array' to display the username but for the rank I don't know how to make it to increase with every user in the table, example:

Username | Rank
usr | 1
usr2 | 2
usr3 | 3


Any idea?

11-25-2011, 12:58 AM
It would look like this.

$i = 0;

while ($row = mysql_fetch_array($query)) {
echo "Rank: $i";

It's also known to start at 1 doing this.

$i += 1;

11-25-2011, 01:34 AM
Thank you!

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum