Quantcast
Channel: CodeIgniter Forums - All Forums
Viewing all articles
Browse latest Browse all 14348

problema pagination library

$
0
0
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 have a problem, my case have by example 25 rows in the database, in the paginate numbers show the numbers 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, to here correct, but when go to the next 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.

Thank you advance.

Viewing all articles
Browse latest Browse all 14348

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>