Welcome Guest, Not a member yet? Register   Sign In
problem with pagination library
#1

(This post was last modified: 10-10-2017, 02:36 AM by oscarenzo.)

Hello all,

I'm starting with codeigniter from some weeks and have a little problem waiting that you can helpme, I'm enabling the paginator module for list rows from table, this is my code:

PHP Code:
function index(){        
 
   $this->load->model("QueryExpense_model");
 
   $this->load->library('pagination');

 
   // init params
 
   $limit_per_page 1;
 
   $start_index = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;
 
   $total_records $this->QueryExpense_model->count_all_rows_expense();
 
   $data['start_index'] = $start_index;

 
   if ($total_records 0){

 
     $data["page_expense_rows"] = $this->QueryExpense_model->list_all_rows_expense($limit_per_page$start_index);
 
      
      $config
['base_url'] = base_url() . 'expense/index';
 
     $config['total_rows'] = $total_records;
 
     $config['per_page'] = $limit_per_page;
 
     $config['num_links'] = 2;
 
     $config['first_link'] = 'Inicio';
 
     $config['last_link'] = 'Último';
 
     $config['next_link'] = '>';
 
     $config['prev_link'] = '<';
 
      
      $this
->pagination->initialize($config);
 
      
      
// build paging links
 
     $data["links"] = $this->pagination->create_links();
 
   }            

         
$this->load->view('header'$data);
         
$this->load->view('expense/body');
        
$this->load->view('footer');        
    } 


But I have a problem, my case I have by example 25 rows in the database table, in the paginate numbers show correctly begin the rows number but, when go to past each page see that in the page 1 (the first-default) the offset is 0, this is correct correct, but when go to the next page the offstet is 22 instead 11, can you help me?

I tested deleting the option "$config['use_page_numbers'] = TRUE;" and fixed but the page number in pagination not match with the url number, by example the real page 1 in url is "app/index/" and in the real page 2 in the url is "app/index/1"

Thank you advance.
Reply
#2

Maybe this will help.

Pagination in CodeIgniter: The Complete Guide
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply




Theme © iAndrew 2016 - Forum software by © MyBB