CodeIgniter Forums
How to make paging from the basics - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=11)
+--- Thread: How to make paging from the basics (/showthread.php?tid=68662)

Pages: 1 2


RE: How to make paging from the basics - InsiteFX - 08-10-2017

Maybe this will help you.

Pagination with CodeIgniter


RE: How to make paging from the basics - neuron - 08-10-2017

read the codeigniter documentation, 
in your db query you did not set offset.
your can find examples here:
https://www.codeigniter.com/userguide3/database/query_builder.html


RE: How to make paging from the basics - neuron - 08-10-2017

read the codeigniter documentation,
in your db query you did not set offset.
your can find examples here:
https://www.codeigniter.com/userguide3/database/query_builder.html


RE: How to make paging from the basics - ciadvantage - 08-11-2017

I have a lot tables on my project and I found DataTable is very helpful. DataTable is very easy to config on how you want the pagination, global search, custom search
so on.

There are couple of ways to get your data to view. I found the best way always to get your query to return as array then json_encode it then make ajax callback to build it

Regards


RE: How to make paging from the basics - Marcolino92 - 08-21-2017

Everything works, the only thing I can not fix is the url, in fact every page is shown as: mysite.com/per_page?=5
I could not do something like mysite.com/page/2

Il mio controller

PHP Code:
   public function index() {
 
       $offset 0;
 
       if ($this->input->get('per_page') != null) {
 
           $offset $this->input->get('per_page');
 
       }
 
       
        $count 
5//number of posts in page 
 
       $filter = array();
 
       $data['post_count'] = $this->post_model->get_active_posts($filter);
 
       $data['title'] = 'Title';
 
       $data['desc'] = 'Enter the description of this page index';
 
       $data['post'] = $this->post_model->get_index($filter$count$offset); 
 
       $config['base_url'] = base_url();
 
       $config['total_rows'] = $data['post_count'];
 
       $config['per_page'] = $count;
 
       $config['next_link'] = "next →";
 
       $config['prev_link'] = "← previous";
 
       $this->pagination->initialize($config);
 
       $data['pagination'] = $this->pagination->create_links();
 
       
        $this
->load->view('templates/header'$data);
 
       $this->load->view('index'$data);