CodeIgniter Pagination Class – Url with get parameter

let say you have paging for search content like this

http://myd0m41n.net/search/result

search is controllers, result is function

and you want to pass parameter $_GET to ur, so the result will see like this

http://myd0m41n.net/search/result?param1=someval&param2=1&param3=false

the problem you need paging to make your (download) data client smaller

the solution you can modify the search function to accept parameter page, and set ‘suffix’ pagination configĀ  value


class search extend CI_Controllers {

...

function result ( $page = 0) {

// your result here

$this->load->library('pagination');

$cfg = array(

'base_url'=>base_url().'search/result',

'use_page_numbers'=>TRUE,

'uri_segment' => 3,

'per_page'=> 20,

'total_rows' => 100,

'suffix' => '?' . http_build_query($_GET, '', "&")

);

$this->pagination->initialize($cfg);

echo $this->pagination->create_links();

}

...

}

and the result will look like this

ci-pagination-get-param

2 thoughts on “CodeIgniter Pagination Class – Url with get parameter

Leave a comment