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

  • SEARCH
  • Home
  • 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 9188279
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T19:58:05+00:00 2026-06-17T19:58:05+00:00

I am, using the Codeigniter pagination library, I am wondering how I can grab

  • 0

I am, using the Codeigniter pagination library,

I am wondering how I can grab the number of the first and last items displayed using the pagination class?

So, if I had 12 results, and per_page was set to 5. I would want

Page 1: Displaying 1 to 5 of 12 results
Page 2: Displaying 6 to 10 of 12 results
Page 3: Displaying 11 to 12 of 12 results.

  • 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-17T19:58:06+00:00Added an answer on June 17, 2026 at 7:58 pm

    Keeping it simple.

    You need 3 variables. Result start, result end (in the page, not the whole) and total result.

    1. You already know the total results (from the pagination). Let’s call it $total.

    2. so, now get the current page ($curpage) value from CI instance. Then,

      $result_start = ($curpage - 1) * $per_page + 1;
      if ($result_start == 0) $result_start= 1; // *it happens only for the first run*
      
    3. for $result_end, you just need to add the per page value but considering it’ll be 1 less,

      $result_end = $result_start+$per_page-1;
      
      if ($result_end < $per_page)   // happens when records less than per page  
          $result_end = $per_page;  
      else if ($result_end > $total)  // happens when result end is greater than total records  
          $result_end = $total;
      
    4. send all those 3 values to view.

      echo "displaying $result_start to $result_end of $total";
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using the codeigniter pagination library to page my search results. I am
I am using codeigniter and its pagination class. It works perfectly and it looks
I'm new in CodeIgniter and read user guide from website. Using pagination class, pagination
I am using Codeigniter pagination library, its working fine. But i am facing problem
Background: Using CodeIgniter with this MongoDB library . This is my first go-round with
I am using CodeIgniter for PHP. Can anybody tell me why is this code
How to create pagination in codeigniter using Ajax? I know how to create simple
I'm using codeigniter pagination here is my code $config['base_url'] = $this->config->base_url().'users/allusers/'; $config['uri_segment'] = 3;
Using CodeIgniter's Active Record class and MySQL, I have a table of posts with
Using codeigniter to generate form. The form has a form_dropdown() <div class=control-group> <?php foreach

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.