php – codeigniter pagination: create links-ThrowExceptions

Exception or error:

I have this piece of code, which uses Codeigniter’s native Pagination Class.

$this->load->library('pagination');
            $config['base_url'] = base_url().'notification/display_notification_info/'.$notification_id;
            $config['total_rows'] = $totalRows;
            $config['per_page'] = $per_page;
            $this->pagination->initialize($config);
            echo $this->pagination->create_links();

It shows the last page by default. So, the links are displayed like so:

< 1, 2, 3

It doesn’t show the last page’s URL.
It should be:

 base_url/3

Where is my mistake?

How to solve:

If your actual page is your last page by default, then it will not show a URL.
But you can still to force it url to current page

Answer´╝Ü

is the url correctly formed (yourdomain.com/notification/display_notification_info/’.$notification_id)?
don’t use base_url()..use site_url()
try it

$config['base_url'] = site_url('notification/display_notification_info/'.$notification_id);

Leave a Reply

Your email address will not be published. Required fields are marked *