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 8628891
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T08:40:03+00:00 2026-06-12T08:40:03+00:00

I have codeigniter applicatin which have pagination code that work like a charm. Pagination

  • 0

I have codeigniter applicatin which have pagination code that work like a charm. Pagination allow the visitor to select how much records he would like to see per page. Now, I would like to add the following:

displaying X to Y from total of Z records.

Now, Z is easy…i have that solved. Can anyone tell me how could I achive this?

Here is the function that i have:

  public function displayAllUsers() 
   { 

        if ($this->uri->segment(3) !="") { 
        $limit = $this->uri->segment(3); 
        } else { 
        $limit = 10; 
        } 

        $offset = 4; 
        $offset = $this->uri->segment(4); 
        $this->db->limit($limit, $offset); 
        $data['users'] = $this->backOfficeUsersModel->get();
        $totalresults = $this->db->get('back_office_users')->num_rows();

        $this->session->set_userdata('totalresults', $totalresults);

        //initializing & configuring paging
        $this->load->library('pagination');
        $config['base_url'] = site_url('/backOfficeUsers/displayAllUsers/'.$limit.'/');
        $config['total_rows'] = $totalresults;
        $config['per_page'] = $limit;
        $config['uri_segment'] = 4;
        $config['full_tag_open'] = '<div class="dataTables_paginate paging_bootstrap pagination"><ul>';
        $config['full_tag_close'] = '</ul></div>';
        $config['cur_tag_open'] = '<li><a href=# style="color:#ffffff; background-color:#258BB5;">';
        $config['cur_tag_close'] = '</a></li>';
        $config['num_tag_open'] = '<li>';
        $config['num_tag_close'] = '</li>';

        $this->pagination->initialize($config); 

       //....irelevant content.....

    } // end of function displayAllUsers

Any help will be deeply appreciated.

  • 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-12T08:40:04+00:00Added an answer on June 12, 2026 at 8:40 am

    It shouldn’t be that hard. In fact, it’s kinda obvious how you can get the value for X and Y if you understand pagination.

    First of all, the difference between X and Y will of course be equal to $limit – 1. The value of X should be equal to the variable, $offset, plus 1 (Offset generally starts from 0 not 1). And from there, I’m sure that you understand that Y is equal to $offset + $limit.

    $X = $offset + 1;
    $Y = $offset + $limit;
    

    In case, you’re at the last page, you’ll want to make sure you have the right value for Y. You’ll need to check the total rows you grab from the database, if it’s less than the limit per page, then change it to something like this

    if (fetched_rows < $limit)
    {
        $Y -= ($limit - fetched_rows); 
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a codeigniter code that is working on local Apache installation. But it
I have a codeigniter multistie install where I have such code that I can
I have a model function that updates a user in my CodeIgniter application: //
I have codeigniter installed at the root directory, and would like to have a
I have a codeigniter application which creates folders using php. The owner of any
In my CodeIgniter application have a common header and footer view, which I include
I'm developing a web based application built on codeigniter which will also have a
I have a CodeIgniter MVC application. I have a model called city that has
I'm creating an application in Codeigniter which will allow anyone, without signing in, to
I have an installation of CodeIgniter. Basically, my directory structure looks like this: |

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.