Jump to content

looking for an algorithm for number progression


sdowney1

Recommended Posts

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

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