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


Messages In This Thread
problem with pagination library - by oscarenzo - 10-09-2017, 09:57 AM
RE: problem with pagination library - by InsiteFX - 10-10-2017, 04:07 AM



Theme © iAndrew 2016 - Forum software by © MyBB