Discover Habbo's history
Treat yourself with a Secret Santa gift.... of a random Wiki page for you to start exploring Habbo's history!
Happy holidays!
Celebrate with us at Habbox on the hotel, on our Forum and right here!
Join Habbox!
One of us! One of us! Click here to see the roles you could take as part of the Habbox community!


Results 1 to 3 of 3

Thread: Simple PHP help

  1. #1
    Join Date
    Jun 2006
    Posts
    4,832
    Tokens
    0

    Latest Awards:

    Default Simple PHP help

    Hey, I think this would be simple to do but I've no idea how to do it.

    I've got a kind of leaderboard, where the top 10 users (1st to 10th - descending) are listed with their, "points". Obviously the user with the most "points" is first. I've managed to do this myself...

    PHP Code:
    $get mysql_query("SELECT * FROM `users` ORDER BY `amount` DESC LIMIT 0 , 10");
    while(
    $each mysql_fetch_array($get)) {
    echo 
    "<tr>
        <td>*RANK*</td>
        <td>"
    .$each['username']."</td>
        <td>"
    .$each['amount']."</td>
      </tr>"
    ;

    And it puts them into a nice table which is displayed. The problem is, see where the *RANK* is? That will say 1st, 2nd, etc. But how do I do it? If I put "1" in there, they all get number 1. So what would I put? I'm not wanting to create an extra table or row for their rank btw...

    Thanks.

  2. #2
    Join Date
    May 2005
    Location
    San Francisco, CA
    Posts
    7,160
    Tokens
    2,331

    Latest Awards:

    Default

    PHP Code:
    $get mysql_query"SELECT * FROM `users` ORDER BY `amount` DESC LIMIT 0 , 10" );

    $i 0;

    while( 
    $each mysql_fetch_array$get ) ) {

        
    $i++;

        echo <<<HTML
    <tr>
        <td>
    {$i}</td>
        <td>
    {$each'username' ]}</td>
        <td>
    {$each'amount' ]}</td>
    </tr>
    HTML;


    I think that's what you want?

  3. #3
    Join Date
    Jun 2006
    Posts
    4,832
    Tokens
    0

    Latest Awards:

    Default

    Quote Originally Posted by Invent View Post
    PHP Code:
    $get mysql_query"SELECT * FROM `users` ORDER BY `amount` DESC LIMIT 0 , 10" );

    $i 0;

    while( 
    $each mysql_fetch_array$get ) ) {

        
    $i++;

        echo <<<HTML
    <tr>
        <td>
    {$i}</td>
        <td>
    {$each'username' ]}</td>
        <td>
    {$each'amount' ]}</td>
    </tr>
    HTML;


    I think that's what you want?
    Exactly what I wanted, spot on! Thanks very much!

Posting Permissions

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