Icy Phoenix

     
 


This forum is locked: you cannot post, reply or edit topics.  This topic is locked: you cannot edit posts or make replies. 
Page 1 of 1
 
 
Reply with quote Download Post 
Post Mysql Query With Rank 
 
Hey guys...

Yeah its me again      

Another thing i need to figure out...

the DB structure is with id, user_id, score,

i have a user_id and a score (number)... and i want to count the entries from the DB... order by score and gives back the Rank/place/count if the user_id matches...

for example:

id=1 user_id=2 score=50 <--------- 1. place
id=2 user_id=3 score=23 <--------- 3. place
id=3 user_id=7 score=34 <--------- 2. place

i hope you can understand what i mean, and help me with that... thanks...
 




____________

Play Games at GamesCampus!
 
KugeLSichASend private messageVisit poster's website  
Back to topPage bottom
Icy Phoenix is an open source project, you can show your appreciation and support future development by donating to the project.

Support us
 
Reply with quote Download Post 
Post Re: Mysql Query With Rank 
 
Code: [Download] [Hide]
  1. SELECT user_id, username, user_rank, user_rank2, user_rank3 ... 
  2. FROM USERS_TABLE 
  3. ORDER BY score DESC 
The PHP code should'nt be too difficult ;-). Something like
Code: [Download] [Hide]
  1. <?php $result = $db->sql_result($sql);  
  2. $place = 0;  
  3. while ($row = $db->sql_fetchrow($result))  
  4. {  
  5.      echo 'Hi I\' ' . $row['username'] . ', id ' . $row['user_id']  . '. My place is ' . ++$place . ', and my first rank is ' . $row['user_rank'] . '<br />'; //feel free to display more ranks  
  6. }  

 



 
InformproSend private message  
Back to topPage bottom
Reply with quote Download Post 
Post Re: Mysql Query With Rank 
 
Thanks Informpro,

you point me in the right direction

I´ve done it like this...  maybe you can take a look.. the code works well, but maybe its not perfect.. let me know if i can tweak it a bit  

Spoiler: [ Show ]


Its for a User Dynamic Signature with data based from Users Profile & Course Handicap site for our Golf MMoG...

herzscheisse
 




____________

Play Games at GamesCampus!
 
Last edited by KugeLSichA on Sun 03 Apr, 2011 16:22; edited 1 time in total 
KugeLSichASend private messageVisit poster's website  
Back to topPage bottom
Reply with quote Download Post 
Post Re: Mysql Query With Rank 
 
(use code syntax=php !)
For the group query, use something like
Code: [Download] [Hide]
  1. AND g.group_id NOT IN (1, 2, 3, 4, 5, 43) 
Much more readable than
Code: [Download] [Hide]
  1.                     AND g.group_id <> 1 
  2.                     AND g.group_id <> 2 
  3.                     AND g.group_id <> 3 
  4.                     AND g.group_id <> 4 
  5.                     AND g.group_id <> 5 
  6.                     AND g.group_id <> 43 
For everything else, it looks good. Nice job ;-).
 



 
InformproSend private message  
Back to topPage bottom
Reply with quote Download Post 
Post Re: Mysql Query With Rank 
 
Ok thanks
 




____________

Play Games at GamesCampus!
 
KugeLSichASend private messageVisit poster's website  
Back to topPage bottom
This forum is locked: you cannot post, reply or edit topics.  This topic is locked: you cannot edit posts or make replies.  Page 1 of 1
 


Display posts from previous:    

HideWas this topic useful?

Link this topic
URL
BBCode
HTML




 
Permissions List
You cannot post new topics
You cannot reply to topics
You cannot edit your posts
You cannot delete your posts
You cannot vote in polls
You cannot attach files
You can download files
You cannot post calendar events


  

 

  cron