I have a value that increases by 1 every 5 views. The MySQL table looks like:
myvalue views increment
10 12 5
For instance, once the views reaches 15, myvalue
will change to 11.
I acomplish this by doing:
$div = $myvalue / $increment;
if (ceil($div) == $div) {
$myvalue = $myvalue + $increment;
}
What I am trying to do is do a quick calculation that would tell me how many more views to go before the next increment. In this example, I would like to return the number 3, since there are 3 more views until the next time myvalue
hits an increment of 5, which is 15.
If myvalue
was 10, views
was 26 and increment
was 25, I need to get the number 24, since there are 24 more views needed before we hit the next increment of 25, which is 50.
Any ideas how to do this?