CodeIgniter Forums
paginating search results - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: paginating search results (/thread-31514.html)



paginating search results - El Forum - 06-22-2010

[eluser]bennyhill[/eluser]
I have a basic search function working for my database but it returns a lot of results I would like to paginate. I can't seem to figure how to hold onto what was entered into the search form for the CI pagination library to work since I'm not using GET variables. Should I store the search term in a cookie?


paginating search results - El Forum - 06-22-2010

[eluser]Burak Guzel[/eluser]
You can store it in session or cookies.

However, then there is a problem if the surfer wants to open multiple tabs with different searches. Then they can start overwriting each other. So you might want to create a unique id for each search, so multiple searches can be stored at the same time.

However, there is another issue. The person can't have a link to these search results (to bookmark it, or email it etc...), as the search parameter data would be temporary. If you want the links to keep working, you can store the search parameters permanently in a table, and assign a "query id". That's what I am doing in a project. So you can have url's this:

http://www.site.com/controller/method/query_id/pagination

Sorry, all I provided is the logic and not the code. I hope it wasn't confusing.


paginating search results - El Forum - 06-22-2010

[eluser]bennyhill[/eluser]
The logic is all i'm looking for. Code is usually no problem. Thanks for the feedback. I wonder how other people DB search in CI?