Jump to content

looking for an algorithm for number progression is now working but


sdowney1

Recommended Posts

can this be improved?

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
Share on other sites

Thanks for the help

 

On one page, I display a series of records in 20 record blocks, with pagination.

Basically, every next, previous, etc... shows another 20 record set.

I create a link displayed with each record based on the record number which is part of each record.

Click that it loads another page which displays just that one record.

On that page I move forward or back one record at a time.

SO, when I post back to the first page that displays the 20 record set, I needed to figure out which set of 20 records to display.

 

I modified what the algorithm needs to this

I need to take in a number from

1 -> 20 and return 1

21 -> 40 and return 21

41 -> 60 and return 41

61 -> 80 and return 61

 

etc....

 

so if your displaying record number 15, it posts back to block of records starting at 1 running to 20

 

so if your displaying record number 25, it posts back to block of records starting at 21 running to 40

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.