sdowney1 Posted February 27, 2011 Share Posted February 27, 2011 looking for an algorithm I need to take in a number from 1 -> 20 and return 1 21 -> 40 and return 2 41 -> 60 and return 3 61 -> 80 and return 4 etc.... yes, it also involves PHP On one page, I display a series of records in 20 record blocks. basically, every next shows another 20 record set. I have a link for each record based on the record number. Click that it loads another page which displays just that one record On that page I move forward of back one record at a time. SO, when I post back to the first page that displays the 20 record set, I need to figure out which set of 20 records to display. Link to comment https://forums.phpfreaks.com/topic/229072-looking-for-an-algorithm-for-number-progression/ Share on other sites More sharing options...
sdowney1 Posted February 27, 2011 Author Share Posted February 27, 2011 this works, but I quess I posted in the wrong forum I can increment every 20, and there will never be more than 10,000 record count $count = 1; while ($count <= 10000) { if (($rpos>=$count) and ($rpos<($count+20))){$dum = $count;break;} $count =($count +20); } echo 'weirdcounter'.$dum.'<BR>'; Link to comment https://forums.phpfreaks.com/topic/229072-looking-for-an-algorithm-for-number-progression/#findComment-1180574 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.