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)

New User

10+ Year Member

joined:Dec 11, 2006
posts: 24
votes: 0


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 Sept 13, 2012 (gmt 0)

Senior Member

joined:Nov 12, 2005
votes: 0

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 Sept 13, 2012 (gmt 0)

New User

10+ Year Member

joined:Dec 11, 2006
votes: 0

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

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members