sw0o0sh Posted May 10, 2010 Share Posted May 10, 2010 Alright, I'm currently working on a Highscores system for this server base I'm coding. The highscores is paged in increments of 20, and is secured with checks by modulus ($start % 20 ==0) (only allows increments of 20). Example: highscores.php?start=20 --> Good, will load the page. highscores.php?start=25 --> Bad, will start row from 0. Alright. Now, you can also view a players stats individually, rather than as a whole (the highscores is the whole). Say a user is rank 35 (variable $x) on the highscores. I want it so, if you click the rank, it will go to the highscores page that has their rank. So in this case it would HAVE to start from 20. How would I approach writing an equation that always check the nearest modulus to their rank? It can't be higher than their rank number, or it would go to the next page, it has to be the modulus before. I'm stumped on how to do this. Any clues or explanations would be helpful! Link to comment https://forums.phpfreaks.com/topic/201269-more-of-a-math-problem-but-coded-in-php-nonetheless/ Share on other sites More sharing options...
sw0o0sh Posted May 10, 2010 Author Share Posted May 10, 2010 Sorry I just noticed there was a math section, move this if necessary please. Link to comment https://forums.phpfreaks.com/topic/201269-more-of-a-math-problem-but-coded-in-php-nonetheless/#findComment-1055910 Share on other sites More sharing options...
Mchl Posted May 10, 2010 Share Posted May 10, 2010 $start = $rank - ($rank % 20); Link to comment https://forums.phpfreaks.com/topic/201269-more-of-a-math-problem-but-coded-in-php-nonetheless/#findComment-1055917 Share on other sites More sharing options...
sw0o0sh Posted May 10, 2010 Author Share Posted May 10, 2010 Very elegant, thank you. Link to comment https://forums.phpfreaks.com/topic/201269-more-of-a-math-problem-but-coded-in-php-nonetheless/#findComment-1055923 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.