I'm developing a sort of game site where every members score is saved for each day. Now I have a database with a table for user information and a table for user score. The user_score table contains:
ID | User_ID | Points | Day
Every day the user gets their graph updated in their personal part of the homepage. The graph shows the users score for each day, with a yAxes displaying the highest score in the top of the graph. I need to emphasis that the graph displays the users own score only, like a form curve for that specific user.
My issue is that I want to display the users position in the ranking system in the graph, not their score...
So my question would be: What do I change in order to give the user his positions not the score? I was trying to add another table in the database to sort this out, but it seems like a pickle.
Should I add another table, should I do anything special in my query? Im using Google Chart API, and trying to follow another thread to make the PHP connection
Simply use this..
$sql=mysql_query("select * from `user_score` order by Points desc");
// Store the user Id in $userid variable of the user whose position you want to show
$position=0;
while($row=mysql_fetch_array($sql))
{
$position+=1;
if($row['User_ID']==$userid)
break;
}
echo $position; // here you got the position of that user.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With