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? Link to comment https://forums.phpfreaks.com/topic/93465-php-points-ranking-help/ 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 />"; } ?> Link to comment https://forums.phpfreaks.com/topic/93465-php-points-ranking-help/#findComment-478861 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 Link to comment https://forums.phpfreaks.com/topic/93465-php-points-ranking-help/#findComment-478867 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.