My problem is that I want to use pagination for different pages but they are in one controller. The pagination for get_all_2017 is successful but the get_all_2018 does not function properly because when I click it only retrieve the first 100 values.
<?php defined('BASEPATH') or exit('No direct script access allowed'); class Product extends CI_Controller { public function _Construct() { parent::__Construct(); cek_login(); } public function index($offset=0) { $this->load->library('pagination'); $config['base_url'] = site_url('product/index'); $config['total_rows'] = $this->M_product->countAll(); $config['per_page'] = 100; $config['full_tag_open'] = '<ul class="pagination">'; $config['full_tag_close'] = '</ul>'; $config['first_link'] = 'First'; $config['last_link'] = 'Last'; $config['first_tag_open'] = '<li class="page-item">'; $config['first_tag_close'] = '</li>'; $config['prev_link'] = '«'; $config['prev_tag_open'] = '<li class="page-item">'; $config['prev_tag_close'] = '</li>'; $config['next_link'] = '»'; $config['next_tag_open'] = '<li class="page-item">'; $config['next_tag_close'] = '</li>'; $config['last_tag_open'] = '<li class="page-item">'; $config['last_tag_close'] = '</li>'; $config['cur_tag_open'] = '<li class="page-item active"><a class="page-link" href="#">'; $config['cur_tag_close'] = '</a></li>'; $config['num_tag_open'] = '<li class="page-item">'; $config['num_tag_close'] = '</li>'; $this->pagination->initialize($config); $data ['product17'] = $this->M_product->get_all_2017($config['per_page'],$offset); $data['pagination'] = $this->pagination->create_links(); $this->template->load('back/template','back/product/data_product', $data); } public function get_product18($offset=0) { $this->load->library('pagination'); $config['base_url'] = site_url('product/get_product18/index'); $config['total_rows'] = $this->M_2018->countAll(); $config['per_page'] = 100; $config['full_tag_open'] = '<ul class="pagination">'; $config['full_tag_close'] = '</ul>'; $config['first_link'] = 'First'; $config['last_link'] = 'Last'; $config['first_tag_open'] = '<li class="page-item">'; $config['first_tag_close'] = '</li>'; $config['prev_link'] = '«'; $config['prev_tag_open'] = '<li class="page-item">'; $config['prev_tag_close'] = '</li>'; $config['next_link'] = '»'; $config['next_tag_open'] = '<li class="page-item">'; $config['next_tag_close'] = '</li>'; $config['last_tag_open'] = '<li class="page-item">'; $config['last_tag_close'] = '</li>'; $config['cur_tag_open'] = '<li class="page-item active"><a class="page-link" href="#">'; $config['cur_tag_close'] = '</a></li>'; $config['num_tag_open'] = '<li class="page-item">'; $config['num_tag_close'] = '</li>'; $this->pagination->initialize($config); $data ['product18'] = $this->M_2018->get_all_2018($config['per_page'],$offset); $data['pagination'] = $this->pagination->create_links(); $this->template->load('back/template','back/product/data_product18', $data); }
<?php defined('BASEPATH') or exit ('No direct script access allowed'); /** * */ class M_product extends CI_Model { public function get_all_2017($limit,$offset) { $this->db->limit($limit); $this->db->offset($offset); return $this->db->get('all_2017')->result(); } function countAll() { return $this->db->get('all_2017')->num_rows(); return $this->db->get('all_2018')->num_rows(); } public function get_all_2018() { $this->db->limit($limit); $this->db->offset($offset); return $this->db->get('all_2018')->result(); }
/table> <br> <?php echo $pagination; ?> </div>
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)