Welcome Guest, Not a member yet? Register   Sign In
How to make paging from the basics
#11

Maybe this will help you.

Pagination with CodeIgniter
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#12

read the codeigniter documentation, 
in your db query you did not set offset.
your can find examples here:
https://www.codeigniter.com/userguide3/d...ilder.html
Reply
#13

read the codeigniter documentation,
in your db query you did not set offset.
your can find examples here:
https://www.codeigniter.com/userguide3/d...ilder.html
Reply
#14

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
Reply
#15

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);
 
     
Reply




Theme © iAndrew 2016 - Forum software by © MyBB