skatermike21988 Posted July 24, 2008 Share Posted July 24, 2008 Hello everyone, I am creating a script that when a user signs up they have the option to input their xbox live gamertag. With the gamertag I pull their gamercard to display on their profile. Well I am trying to make a leaderboard that displays leaders by their gamerscore. So.. I have made a cron job that checks and gathers the required info and inserts it into the mysql which works fine. At the very end of the cron job I have it update their rank position which is where I am having the problem. The code looks like this for the update: $getrank = mysql_query("SELECT * FROM xboxleaderboard ORDER BY `gamerscore` DESC;"); $rank=0; while($info = mysql_fetch_array( $getrank )) { $userid = $info['userid']; $rank=$rank+1; $updaterank = "UPDATE `xboxleaderboard` SET `rank` = '$rank' WHERE userid = '$userid'"; $updaterankresult = mysql_query($updaterank); } the $rank adds fine but mysql is not pulling the data right my database looks like this: -------------------------------- gamerscore| gamertag | rank -------------------------------- 450 |skatermike219 | 1 21922 |NeutralX2 | 3 36607 |Gemini711 | 2 --------------------------------- That's what it looks like after the script runs as you can see skatermike219 should not be ranked number 1 and of course Gemini711 should not be ranked number 2 it should be: -------------------------------- gamerscore| gamertag | rank -------------------------------- 450 |skatermike219 | 3 21922 |NeutralX2 | 2 36607 |Gemini711 | 1 -------------------------------- Any help appreciated this is really starting to bug me. Thanks Link to comment https://forums.phpfreaks.com/topic/116389-solved-problem-with-mysql-order-by/ Share on other sites More sharing options...
samshel Posted July 24, 2008 Share Posted July 24, 2008 what is data type for column gamerscore, i think it is varchar ? if yes, try changing to int or big int Link to comment https://forums.phpfreaks.com/topic/116389-solved-problem-with-mysql-order-by/#findComment-598487 Share on other sites More sharing options...
skatermike21988 Posted July 24, 2008 Author Share Posted July 24, 2008 AWESOME thank you that was my problem Link to comment https://forums.phpfreaks.com/topic/116389-solved-problem-with-mysql-order-by/#findComment-598490 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.