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
Share on other sites

Do you want to find the user with the 3rd highest strength?  Eg

 

User A:  Strength 100

User B:  Strength 90

User C:  Strength 85  <-- this one

User D:  Strength 80

 

And is strength stored in the grpgusers table as "strength"?

Link to comment
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

 

 

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

<?

$result= mysql_query("SELECT * FROM `grpgusers` ORDER BY `grpgusers`.`strength` DESC LIMIT 0 , 30");

while($line3 = mysql_fetch_array($result, MYSQL_BOTH)) {

echo "<tr><td width='17%' align='center'><font color='#00BFFF'>".$line3['id']."</font></td></tr>"; ?>

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • 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

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.