Jump to content

Help plz getting rank


grant09

Recommended Posts

ok i have been at this for about 3 days now just cant seem to get it to work ranked in my game well when you go to halloffame it tells you wot your rank is well i want my rank to tell me wot i rank in the game for Strength in my gym so if i was ranked 3 in my game it wld say 3 in all the game and so on for speed ect.. any help wld be great

this is wot am workin with

$result= mysql_query("SELECT * FROM `grpgusers` ORDER BY `grpgusers`.`strength` DESC
LIMIT 0 , 1");
while($line3 = mysql_fetch_array($result, MYSQL_BOTH)) {

any help thanks

Link to comment
https://forums.phpfreaks.com/topic/229517-help-plz-getting-rank/
Share on other sites

strength

100000 <----highest

10000

0000

000

00

0<---- lowest

if the user is 1000000 in strength and he has the most in the game he would be ranked 1 in the game

 

0  this user would be the lowest in the game and he would be ranked last so if there is 37 users he would be ranked 37

 

and i want to display the number they are ranked in the game so the strongest would be ranked 1

 

 

 

You could do:

 

$result= mysql_query("SELECT * FROM `grpgusers` ORDER BY `grpgusers`.`strength` DESC");
$rank = 1;
while($line3 = mysql_fetch_array($result, MYSQL_BOTH)) {
    print "Rank $rank: ";
    # Display data from $line3

    $rank = $rank + 1;
}

 

$rank will increase by 1 each time through the loop.

You could do:

 

$result= mysql_query("SELECT * FROM `grpgusers` ORDER BY `grpgusers`.`strength` DESC");
$rank = 1;
while($line3 = mysql_fetch_array($result, MYSQL_BOTH)) {
    print "Rank $rank: ";
    # Display data from $line3

    $rank = $rank + 1;
}

 

$rank will increase by 1 each time through the loop.

 

In the post above I added a variable $rank.  This tells you what rank each user is.

You could do it is 2 queries:

 

set @strength = (select strength from grpgusers where user_id = 3);
select count(*) as rank from grpgusers where strength >= @strength;

 

or

 

select count(*) as rank from grpgusers where strength >= (select strength from grpgusers where user_id = 3);

  • 2 weeks later...

ok sorry about the wait am just back from holiday ok i will try explain how i want to to show

 

 

1 200100675456 <<<-- jeffy i Want on his profile to say .....you are ranked [1] with out the row of other numbers so its just an individual number like[1]

2 484918

3 210000

4 101000

5 25500

6 2651

7 1000

8 335

9 295

10 255

11 130

12 79

13 10 <<<- jimmy i Want on his profile to say he is ranked [13] in all of my game

 

but the code that am trying to do this is not giving me that sum its giving me am ranked 2 and so are all the users

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.