Pagination with search results in Codeigniter
With simple queries I'm able to produce pages with nice pagination links. However, if the query is generated through some sort of search filter, I'm not sure how to pass the $_POST data from page to page.
Usually I can do th开发者_如何转开发is ... www.domain.com/search.php?id=200&type=host&rack=3&os=redhat%5
However, with CI's URI library, I'm using "pretty urls," hence my URL is more like www.domain.com/search/page/1
Appending the rest of the variables doesn't make sense nor will I think it will work. Any ideas on how to tackle this issue?
Why don't you just store the variables you need in a user session? Here is some information about how to use a session to store information about a user with codeigniter: http://codeigniter.com/user_guide/libraries/sessions.html
Format your URI like so:
index.php/controller/method/id/200/type/host/rack/3/os=redhat%5/page/2
You can then use $this->uri->uri_to_assoc(n)
to turn that URI into key-value pairs. See:
http://codeigniter.com/user_guide/libraries/uri.html
Please have a look the link below. This article show you have to pass parameters on pagination without turn on enable query string settings.
http://pujanpiya.com.np/?q=node/37
Hope this help!
If your using the built in pagination class, just make a separate search method on your controller and provide it with the pagination info...
FYI, there is a great jQuery Plugin that takes care of alot of table related work for you. Datatables.net
I just wrote a library that handles search, pagination, sorting and limiting.. Check it out here.
http://datatables.dyndns-web.com/
精彩评论