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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T15:03:51+00:00 2026-06-13T15:03:51+00:00

so many pagination question on stackoverflow, but i can’t see it with codeigniter, so

  • 0

so many pagination question on stackoverflow, but i can’t see it with codeigniter, so here it goes.

we need to look at these picture
enter image description here

and here

enter image description here

and here

enter image description here

i have ten record on the table, and the link is not working, here is the controller/index

$query = $this->m_kategorimaterial->get();  
    $config['base_url'] =  base_url().'index.php/c_kategorimaterial/index/';
    $config['total_rows'] = $query->num_rows();
    $config['per_page'] = 5; 
    $this->pagination->initialize($config);
    $data['rows'] = $query->result();
    $data['title'] = 'QB Kategori Material';
    $this->load->view('menu',$data);
    $this->load->view('v/vkategorimaterial');

and here is the model

 $this->db->order_by('Kode_Kategori_Material_Jasa','DESC');
    $query = $this->db->get('ms_kategori_material');
    return $query;

why does the link is not working ? how do i resolve it ? Thank you stackoverflow

  • 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-13T15:03:52+00:00Added an answer on June 13, 2026 at 3:03 pm

    Where are you calling the offset in the data gathering query? You need to provide an offset to the query so it knows which records to get.

    You’ll also have to change the total_rows to a second query that queries the entire table for total records since your new query only returns enough records for one page.

    Model:

    $this->db->order_by('Kode_Kategori_Material_Jasa','DESC');
    $query = $this->db->get('ms_kategori_material', $limit, $offset);
    return $query;
    
    function getRecordCount() {
    
    $query=$this->db->get('ms_kategori_material');
    $result = $query->num_rows();
    return $result;
    }
    

    Controller:

    $config['base_url'] =  base_url().'index.php/c_kategorimaterial/index/';
    $config['total_rows'] = $query->num_rows();
    $config['per_page'] = 5; 
    $this->pagination->initialize($config);
    $query = $this->m_kategorimaterial->get($config['per_page'],$this->uri->segment(3));
    $data['rows'] = $this->m_kategorimaterial->getRecordCount();
    $data['title'] = 'QB Kategori Material';
    $this->load->view('menu',$data);
    $this->load->view('v/vkategorimaterial');
    

    Seems you could use a small explanation of what’s happening here. To do pagination CI (or any application) needs at minimum 3 variables.

    limit – how many records per page should I show, and consequently how many records does my query return.

    offset – Where does the query start asking for records, with CI this is where the uri segment comes in, it’s controlled partially by the limit so if you have 8 as a limit (per_page) each query increments the offset by 8. So page 1 queries the database for the first 8 records starting at the beginning, page two the first 8 records starting at record 9 and so on.

    Total records – This is the total matching records for the query in the entire table(s). This is how the application determines how many pages there are in total and whether a second page is required at all. This query has no limit or offset because you want all the matching records and not a partial return.

    The actual pagination of the data is carried out by the database query. CI just tells the database which records it needs.

    Hope that helps clear things up.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to implement pagination in my Servlet/EJB/JPA-Hibernate project, but I can't figure
I'm doing a pagination feature using Codeigniter but I think this applies to PHP/mySQL
Similar to this question — but due to my ineptitude with CakePHP, I can't
I created grid in magento backend, but pagination doesn't work. No matter how many
I've seen many examples of pagination like what's shown below. However, I want to
I am currently coding a pagination script into many parts of my site, this
I'm placing an entire pagination script into a function so I can use it
I've found many similar questions but nothing with quite the answer I'm after. Part
I need to display many pages of news in a site. Should I do
Hello I am trying to create some simple pagination, but my php skills are

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.