Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9216247
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T02:22:35+00:00 2026-06-18T02:22:35+00:00

For example, let’s say: $startIndex = 21; $totalItems = 100; $itemsPerPage = 10; $totalPages

  • 0

For example, let’s say:

$startIndex = 21; 
$totalItems = 100;
$itemsPerPage = 10;
$totalPages = ceil($totalItems / $itemsPerPage);  // (10)

$currentpage = //I am stumped here.

What would $currentpage be, based on $startIndex?

I’m working on pagination and it’s kicking my butt. I know it’s probably some very simple math, but I can’t think right now.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T02:22:37+00:00Added an answer on June 18, 2026 at 2:22 am

    With 10 items per page and assuming your item count/numbering starts at 1, page 1 contains items 1 to 10, page 2 contains items 11 to 20, page 3 contains 21 to 30, and so on.

    So,

    $currentPage = ceil(($startIndex - 1) / $itemsPerPage) + 1;
    

    I used ceil() to make sure you have an integer number, which is rounded up so the current page number is correct.


    If your item count starts at 0, so page 1 contains items 0 to 9, you can skip the - 1 and + 1 parts of the formula:

    $currentPage = ceil(($startIndex) / $itemsPerPage);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's a problem I experience (simplified example): Let's say I have several tables: One
Maybe a silly question but here goes anyway. Example: Let's say I have one
A simple example: Let's say I have one alias being sourced somewhere as: alias
There is an example (let us say in a file named mybatch.bat ): @echo
Is there any way to get PDF document text language? Example: Let's say I
Let's say for example I wanted to echo You are using Windows! or You
Really simple example: Let's say I have this table: ID Name GUID1 John GUID2
how can I replace 2 strings in the same time? for example let's say
I write some code to learning F#. Here is a example: let nextPrime list=
What's the best way to thread work (methods) in c#? For example: Let's say

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.