lJesterl Posted February 28, 2008 Share Posted February 28, 2008 Hey guys if someone would aim me LJesterL I could explain a little better. Basicly i'm writing a ladder system and i'm done with everything except adjusting the ranks when a loss is reported. I thought I could do it but I cant figure it out. Here's basicly how I need it to work. I need to select id from ladder_$li[ladderid] ORDER by points then I need to update the ranks and set ranks 1 through whatever based on who has the highest points to who has the lowest and if they have 0 points do not update the rank. Can someone help me do this? Quote Link to comment Share on other sites More sharing options...
Kingy Posted February 28, 2008 Share Posted February 28, 2008 well to list all the ranks you could go.. <?php $rank = 0; $query = mysql_query("SELECT * FROM ladder WHERE points > 0 ORDER BY points") or die(mysql_error()); while($row = mysql_fetch_array($query)) { $user = $row['user']; $points = $row['points']; $rank++; echo "$user is ranked $rank with $points points<br />"; } ?> That would list all users as USER is ranked 1 with 10 points USER2 is ranked 2 with 7 points etc etc now to update them would be easy.. <?php $rank = 0; $query = mysql_query("SELECT * FROM ladder WHERE points > 0 ORDER BY points") or die(mysql_error()); while($row = mysql_fetch_array($query)) { $ladderid = $row['ladderid']; $user = $row['user']; $points = $row['points']; $oldrank = $row['rank']; $rank++; $update = mysql_query("UPDATE ladder SET rank='$rank' WHERE ladderid='$ladderid'") or die(mysql_error()); echo "$user is now ranked $rank with $points points. Their old rank was $oldrank<br />"; } ?> Quote Link to comment Share on other sites More sharing options...
lJesterl Posted February 28, 2008 Author Share Posted February 28, 2008 thank you im going to play around with this. I may come back to you for some more help if u dont mind Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.