Sayantan Das Sayantan Das - 6 months ago 45
PHP Question

Codeigniter search with pagination is not working

I am trying to implement search with pagination in codeigniter. The problem I am facing is this: The default url for the searched term looks like this

But as soon as i select the second page of the link the url changes to

so I am losing the search parameters and the page basically list all the results from the database.

My base URL is like this
$config['base_url'] = base_url() . '/companies/staff/staff_search';

I have changed the base url to this according to this post (I've hard coded the url to check)

$config['base_url'] = base_url('/companies/staff/staff_search') . "?company_staff_id=&name=r&address=&email=" ;

As a result the url becomes like this

Which searches for an email
. Any suggestion will be appriciated


In this case you can use page query string:

    $config['base_url'] = base_url('/companies/staff/staff_search') . "?company_staff_id=&name=r&address=&email=" 
    $config['enable_query_strings'] = true;
    $config['page_query_string'] = TRUE;

So you will have &page=1 in your $_GET parameters for next page.

The URL address should be:

This may help you to fix the problem.