Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Nov 2011
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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?

  • #2
    Senior Coder
    Join Date
    Apr 2010
    Posts
    1,422
    Thanks
    69
    Thanked 102 Times in 101 Posts
    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 7 years. My business:
    American Made Signs

  • #3
    New Coder
    Join Date
    Nov 2011
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •