Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP

Why can't I show my pagination links in my CodeIgniter app?

Hello all,

I'm developing this app on CodeIgniter. I want to have a pagination system. I've provided my codes below. The thing is, after initializing my pagination and echoing my pagination links, I don't get any links! The DIV is empty. can you help me solve this? It's so important to me.

Here's my Pagination Initialization function:

<?php
public function init($uri,$total_rows,$per_page=5,$segment=3){
           $this->load->library('pagination');
           $config['per_page'] = $per_page;
           $config['uri_segment'] = $segment;
           $config['base_url'] = base_url().$uri;
           $config['total_rows'] = $total_rows;
           $config['use_page_numbers'] = TRUE;
           $config['full_tag_open'] = '<ul class="pagination">';
           $config['full_tag_close'] = '</ul>';
           $config['first_link'] = 'First';
           $config['first_tag_open'] = '<li>';
           $config['first_tag_close'] = '</li>';
           $config['last_link'] = 'Last';
           $config['last_tag_open'] = '<li>';
           $config['last_tag_close'] = '</li>';
           $config['cur_tag_open'] = '<li class="active"><a>';
           $config['cur_tag_close'] = '</a></li>';
           $config['num_tag_open'] = '<li>';
           $config['num_tag_close'] = '</li>';
           $config['next_tag_open'] = '<li>';
           $config['next_tag_close'] = '</li>';
           $config['prev_tag_open'] = '<li>';
           $config['prev_tag_close'] = '</li>';
           $this->pagination->initialize($config);
           return $config;    
       }

Here's my pagination function in my controller

<?php
$data['pagination'] = $this->init("blog/index",round(count($data['posts'])/5, 0, PHP_ROUND_HALF_UP),5,3);

1 Answer

I doubt there would be anyone on this forum that can help you

you'd be better off asking this in a codeigniter forum community