Welcome Guest, Not a member yet? Register   Sign In
Pagination with $_GET => double page variables
#1

[eluser]teomor[/eluser]
I'm using the $_GET version of the pagination. This is my config:
Code:
$config['page_query_string'] = TRUE;
$config['query_string_segment'] = 'offset';
and this is my controller:
Code:
$this->pagination->base_url = site_url()."admin/users/?".http_build_query($_GET);
$this->pagination->total_rows = $total_rows; // total rows from the db
$this->data['pages'] = $this->pagination->create_links(); // this is the html output
Now, when I change to another page, the previous value of offset is stuck in the URL, but the new offset variable appears also, like this: admin/users/?offset=&offset=5. I looked at the Pagination class and there's actually no attempt to remove the existing variable so... you tell me, is this a bug?
#2

[eluser]ballmatic[/eluser]
I had the same problem as you. After some digging around on PHP.net, I came across the following which works wonders:

Code:
http_build_query( Array( 'offset' => null ) + $this->input->get(NULL, TRUE) )

Basically, you use the first Array to NULL out any values you want. You used the variable "offset", so I used that in this example.




Theme © iAndrew 2016 - Forum software by © MyBB