CodeIgniter Forums
Pagination problem - Printable Version

+- CodeIgniter Forums (
+-- Forum: Using CodeIgniter (
+--- Forum: General Help (
+--- Thread: Pagination problem (/showthread.php?tid=1581)

Pagination problem - gabrielpasv - 03-23-2015

Hi Guys,

I am new to codeigniter and I am having a problem when working with pagination.

The $this->pagination->create_links() is always empty it doesn't return anything even if I echo it on controller or in the view

Please see my controller, as this is a test I didn't create a model

PHP Code:
public function index() {
$config['base_url'] = '';
$config['total_rows'] = $this->db->get('data')->num_rows();
$config['per_page'] = 10;
$config['num_links'] = 20;
//        echo $config['base_url'];
//        echo $config['total_rows'];
//        echo $config['per_page'];
//        echo $config['num_links'];
$data['records'] = $this->db->get('data'$config['per_page'], $this->uri->segment(3));
$data['links'] = $this->pagination->create_links();
print_r($data['links']) ;

RE: Pagination problem - CroNiX - 03-23-2015

And what uri_segment are you using to display your pagination options?

RE: Pagination problem - gabrielpasv - 03-23-2015

didn't get your question, sorry. I am following a video tutorial

I forgot to pass $data to the view. However still not working

my controller
public function index() {
$config['base_url'] = '';
$config['total_rows'] = $this->db->get('data')->num_rows();
$config['per_page'] = 10;
$config['num_links'] = 20;


$data['records'] = $this->db->get('data', $config['per_page'], $this->uri->segment(3));
$data['links'] = $this->pagination->create_links();

$this->load->view('site_view', $data);


my view

<div id="container">
<h1>Super Pagination with codeIgniter</h1>
<?php echo $this->pagination->create_links(); ?>
<?php echo $links; ?>

RE: Pagination problem - CroNiX - 03-23-2015

See the options for the pagination library. By default, CI looks at segment 3 to determine what page it's currently on, but it looks like you are using segment 4 since your base_url is (segment 1=TUTPagination, 2=site, 3=index, 4=should be page number). So right now it thinks the page number is "index" and probably not being able to load the content for that "page" since it doesn't exist.

RE: Pagination problem - gabrielpasv - 03-23-2015

I was able to make it work.. the problems was number of rows in my database