Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function index() {
- $this->load->model('Customer');
- $this->load->library('pagination');
- $config = [
- 'base_url' => base_url("/"),
- 'per_page' => 10,
- 'total_rows' => $this->Customer->get_num_rows(),
- 'uri_segment' => 5,
- 'first_tag_open' => '<li>',
- 'first_tag_close' => '</li>',
- 'last_tag_open' => '<li>',
- 'last_tag_close' => '</li>',
- 'full_tag_open' => '<ul class="pagination">',
- 'full_tag_close' => '</ul>',
- 'next_tag_open' => '<li>',
- 'next_tag_close' => '</li>',
- 'prev_tag_open' => '<li>',
- 'prev_tag_close' => '</li>',
- 'num_tag_open' => '<li>',
- 'num_tag_close' => '</li>',
- 'cur_tag_open' => '<li class="active"><a>',
- 'cur_tag_close' => '</a></li>',
- ];
- $this->pagination->initialize($config);
- $customers = $this->Customer->getCustomers($config['per_page'], $this->uri->segment($config['uri_segment']));
- $this->load->view('home', ['records'=>$customers]);
- }
- class Customer extends CI_Model {
- public function __construct() {
- $this->load->database();
- }
- public function getCustomers($limit, $offset) {
- $this->db->limit($limit, $offset);
- $query = $this->db->get('customers');
- return $query->result();
- }
- }
- <div class="pagination-container text-center">
- <?php echo $this->pagination->create_links(); ?>
- </div>
- http://localhost/cicrud/10
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement