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 10 of 10

Thread: PHP Ranking?

  1. #1
    Join Date
    May 2006
    Location
    Hull
    Posts
    7,701
    Tokens
    2,430
    Habbo
    Moh

    Latest Awards:

    Default PHP Ranking?

    I have researched on how to do this, but I could only find the ranks for a full list.
    Does any one know how I would get thank rank of a specific user?

    So in the database, it looks like:

    username -- points
    ------------------
    jack -- 50
    ryan -- 65
    skier -- 48
    david -- 67

    So if you was logged in as skier, it would say "Your current rank is 4"
    and for ryan, it would say "Your current rank is 2" etc..

    +Rep for any help

  2. #2
    Join Date
    Jul 2008
    Posts
    14
    Tokens
    0

    Default

    $1 = mysql_query("select * from TABLE where `USER`='session'");
    $2 = mysql_fetch_array($1);
    echo("<b>" . $2[username] . "</b> - " . $2[points] . "");

    Im sorta new to php.. Sorry if this is the wrong thing but is that the sort of thing you mean?

  3. #3
    Join Date
    Oct 2005
    Location
    Melbourne, Australia
    Posts
    7,554
    Tokens
    0

    Latest Awards:

    Default

    Wouldn't it be easier if you had the list in descending order from the most points to the least?

  4. #4
    Join Date
    Jul 2008
    Posts
    14
    Tokens
    0

    Default

    ops, I understand what you mean now,
    I didn't read the post properly...

  5. #5
    Join Date
    Oct 2007
    Posts
    824
    Tokens
    71

    Latest Awards:

    Default

    I think you would order them by interger then pull them by id?

  6. #6
    Join Date
    May 2006
    Location
    Hull
    Posts
    7,701
    Tokens
    2,430
    Habbo
    Moh

    Latest Awards:

    Default

    Quote Originally Posted by Lemonade View Post
    $1 = mysql_query("select * from TABLE where `USER`='session'");
    $2 = mysql_fetch_array($1);
    echo("<b>" . $2[username] . "</b> - " . $2[points] . "");

    Im sorta new to php.. Sorry if this is the wrong thing but is that the sort of thing you mean?
    Quote Originally Posted by Blinger View Post
    Wouldn't it be easier if you had the list in descending order from the most points to the least?
    Quote Originally Posted by Fazon View Post
    I think you would order them by interger then pull them by id?
    What I want it to do is order them all by points DESC and then giving me the position of the entry out the full list.

  7. #7
    Join Date
    Oct 2007
    Posts
    824
    Tokens
    71

    Latest Awards:

    Default

    Oh,
    ("SELECT * FROM changeme WHERE changeme ORDER BY rank desc");

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

    Latest Awards:

    Default

    Quote Originally Posted by Jack120 View Post
    What I want it to do is order them all by points DESC and then giving me the position of the entry out the full list.
    PHP Code:
    $query mysql_query"SELECT * FROM `changeme` ORDER BY `points` DESC" );

    $i 1;

    while( 
    $f mysql_fetch_array$query ) )
    {

        echo 
    "["$i "] "$f["username"] . " - "$f["points"] ." points<br />";

        
    $i++;
        

    That'd order them like:

    [1] David - 67 points
    [2] Ryan - 65 Points
    [3] Jack - 50 points
    [4] Skier - 48 points

    I think that's what you want?

  9. #9
    Join Date
    Sep 2006
    Location
    Evanston, Illinois.
    Posts
    2,361
    Tokens
    0

    Latest Awards:

    Default

    PHP Code:
    <?php

    $i 
    0;

    $q mysql_query("select * from ranks where user='jack'");
    $f mysql_fetch_array($q);

    $wq mysql_query("select * from ranks where user not like 'jack'");
    $wf mysql_fetch_array($wq);
    $top 1;

    foreach(
    $wq as $val => $k) {
    if(
    $wq['points'] > $f['points']) {
    ++
    $top;
    }

    echo 
    "Your rank is " $top;

    ?>
    untested will work with tweaks - probably a better way
    How could this hapen to meeeeeeeeeeeeeee?lol.

  10. #10
    Join Date
    May 2006
    Location
    Hull
    Posts
    7,701
    Tokens
    2,430
    Habbo
    Moh

    Latest Awards:

    Default

    Oops, forgot to post that I have done it

    I used the way simon did it, but when it got you your rank, it stopped and set a variable as $x. Then it just returned the variable

Posting Permissions

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