Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-25-2011, 12:40 AM   PM User | #1
Cyber4Hacks
New Coder

 
Join Date: Nov 2011
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Cyber4Hacks is an unknown quantity at this point
Incrementing fetch_array()

Hello!

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

etc.

Any idea?
Cyber4Hacks is offline   Reply With Quote
Old 11-25-2011, 12:58 AM   PM User | #2
myfayt
Senior Coder

 
Join Date: Apr 2010
Posts: 1,156
Thanks: 46
Thanked 95 Times in 94 Posts
myfayt can only hope to improve
It would look like this.

PHP Code:
$i 0;

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

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

PHP Code:
$i += 1
__________________
Been a sign maker for 5 years. My business:
American Made Signs
myfayt is offline   Reply With Quote
Old 11-25-2011, 01:34 AM   PM User | #3
Cyber4Hacks
New Coder

 
Join Date: Nov 2011
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Cyber4Hacks is an unknown quantity at this point
Thank you!
Cyber4Hacks is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:01 AM.


Advertisement
Log in to turn off these ads.