Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Point looping



9:57 pm on Sep 12, 2012 (gmt 0)

5+ Year Member


I'm not sure what this is called, if there is an algorithm for this so have had troubles searching for it.

It seems pretty basic but I seem to keep getting stuck in the same place.

I have points and I have a point threshold, as points keep getting accumulated (which is a different number each time) I need to determine if the current points have just passed the threshold or not. So say I have 489 points, then the next amount of points brings the total to 511 points and my max is 500, I have a remainder of 11.

Here's my PHP code:

$current_points = 511;
$min_points = 500;

if($current_points > $min_points){
$points_multiple = $current_points % $min_points;

if($points_multiple > 0){
$points_needed = $min_points - $points_multiple;
$points_needed = 0;
$points_needed = $min_points - $current_points;

Note: The next time this threshold is reached would be after 1000 points, and $min_points could be changed at anytime.

I do have access to the number of points per transaction, so I was thinking I could get that last number and subtract it from the current and if $points_multiple is over the threshold cycle but $current_points - $last_points is under, then I know it has just passed the threshold, but I'd like to know if there's a better way.



7:05 pm on Sep 13, 2012 (gmt 0)

WebmasterWorld Senior Member eelixduppy is a WebmasterWorld Top Contributor of All Time 5+ Year Member

Not sure I understand the whole issue here. Doesn't this work?

$currentPoints = 511;
$threshold = 500;

if($currentPoints > $threshold) {
echo 'Passed threshold';
$threshold += 500; // increase threshold value


7:48 pm on Sep 13, 2012 (gmt 0)

5+ Year Member

I ended up solving the problem by using the method I stated above. Thanks though.

Featured Threads

Hot Threads This Week

Hot Threads This Month