Reputation: 49
I use codeigniter pagination class to paginate my records, below you can see my code
$data['success'] = "";
$data['error'] = "";
$data['offset'] = 0;
$this->load->library('pagination');
$per_page = 4;
$total = $this->m_workshop->totalworkshoppay();
$baseUrl = site_url('sitemanager/workshop/workshopayment');
$data['query'] = $this->m_workshop->getallwpay($per_page, (int) $this->uri->segment(4));
$confignew['base_url'] = $baseUrl;
$confignew['total_rows'] = $total;
$confignew['per_page'] = $per_page;
$confignew['uri_segment'] = '4';
$this->pagination->initialize($confignew);
$data['offset'] = (int) $this->uri->segment(4);
$this->load->view('sitemanager/workshop/viewallworkshoppay',$data);
and i use <?php echo $this->pagination->create_links(); ?>
code in my view page to show pagination links.But the pagination links are not showing in browser.When i print $data['query']
the records are limited according to $per_page
variabe.
Upvotes: 0
Views: 2855
Reputation: 18695
Create the links in your controller first. You also have to make sure you're grabbing enough records to make links. I usually set my per page to 1 when first setting it up to make sure it's working.
Controller:
$data['success'] = "";
$data['error'] = "";
$data['offset'] = 0;
$this->load->library('pagination');
$per_page = 4;
$total = $this->m_workshop->totalworkshoppay();
$baseUrl = site_url('sitemanager/workshop/workshopayment');
$data['query'] = $this->m_workshop->getallwpay($per_page, (int) $this->uri->segment(4));
$confignew['base_url'] = $baseUrl;
$confignew['total_rows'] = $total;
$confignew['per_page'] = $per_page;
$confignew['uri_segment'] = '4';
$this->pagination->initialize($confignew);
$data['pages'] = $this->pagination->create_links();
$data['offset'] = (int) $this->uri->segment(4);
$this->load->view('sitemanager/workshop/viewallworkshoppay',$data);
View:
echo $pages;
Upvotes: 1