Welcome Guest, Not a member yet? Register   Sign In
Pagination Problem
#1

[eluser]Unknown[/eluser]
Hi guys, I'm having trouble getting my pagination to work. I have setup a model to get results based on a users search terms using a like query.

Code:
$this->db->like('product', $this->input->post('q'));

The search works fine until I go to the paginated links, then I receive this error:

Error Number: 1064
SELECT * WHERE `product` LIKE '%%

I'm guessing the post data is being reset when I click a paginated link. Any suggestions would be greatly appreciated.

Sorry, I'm new to programming and this is probably a silly question but it's got me stumped.
#2

[eluser]brianw1975[/eluser]
this is one thing i haven't tried yet. if it were me, I'd make the form post via GET and then pagination can end up being like mysite.com/q/page/20

where q is the search term and 20 is the offset - at least it is in my work

HTH
#3

[eluser]Armchair Samurai[/eluser]
As you suspected, you need to somehow retain the query info otherwise you'll get the error. There are several ways you could do this, but you basically want to end up with a url something like
Code:
http://foo.com/controller/function/query_string/pagination
With CI's strict security (until you start monkeying around with the settings), it may not be immediately obvious how to pass the query as part of the URL, but I've found success by encoding the string. Try looking into urlencode() or base64_encode() - with slight modification I've used both successfully in the past to overcome the problem you're describing.
#4

[eluser]Unknown[/eluser]
Thank you for your suggestions, I went with urlencode and it's exactly what I was looking for, thanks again.




Theme © iAndrew 2016 - Forum software by © MyBB