Advertisement
Guest User

Untitled

a guest
Aug 16th, 2017
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. public function index() {
  2. $this->load->model('Customer');
  3. $this->load->library('pagination');
  4. $config = [
  5. 'base_url' => base_url("/"),
  6. 'per_page' => 10,
  7. 'total_rows' => $this->Customer->get_num_rows(),
  8. 'uri_segment' => 5,
  9. 'first_tag_open' => '<li>',
  10. 'first_tag_close' => '</li>',
  11. 'last_tag_open' => '<li>',
  12. 'last_tag_close' => '</li>',
  13. 'full_tag_open' => '<ul class="pagination">',
  14. 'full_tag_close' => '</ul>',
  15. 'next_tag_open' => '<li>',
  16. 'next_tag_close' => '</li>',
  17. 'prev_tag_open' => '<li>',
  18. 'prev_tag_close' => '</li>',
  19. 'num_tag_open' => '<li>',
  20. 'num_tag_close' => '</li>',
  21. 'cur_tag_open' => '<li class="active"><a>',
  22. 'cur_tag_close' => '</a></li>',
  23. ];
  24. $this->pagination->initialize($config);
  25. $customers = $this->Customer->getCustomers($config['per_page'], $this->uri->segment($config['uri_segment']));
  26. $this->load->view('home', ['records'=>$customers]);
  27. }
  28.  
  29. class Customer extends CI_Model {
  30. public function __construct() {
  31. $this->load->database();
  32. }
  33.  
  34. public function getCustomers($limit, $offset) {
  35. $this->db->limit($limit, $offset);
  36. $query = $this->db->get('customers');
  37. return $query->result();
  38. }
  39. }
  40.  
  41. <div class="pagination-container text-center">
  42. <?php echo $this->pagination->create_links(); ?>
  43. </div>
  44.  
  45. http://localhost/cicrud/10
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement