Jump to content

More of a math problem, but coded in PHP nonetheless.


sw0o0sh

Recommended Posts

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!

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.