CodeIgniter Forums
Search form Dillema - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Search form Dillema (/showthread.php?tid=28529)



Search form Dillema - El Forum - 03-13-2010

[eluser]frist44[/eluser]
I have a search form that uses pagination to show various pages of results. At first, I set up the page to all be from the same function ("browse"). I just looked to see if there was post data, and if so, considered it a search and then went through the search code to pull out specific records and then push them into the view. Problem with this setup was that, in the summary view, there is an abbreviated version with a details button next to one that goes to a details page to see the whole listing (think ebay style...). When the user would hit the back button, the browser would pop up a warning to repost the data. This didn't seem very elegant and normal. The other problem was that after search results were displayed, if you clicked on one of the pagination links, it would not post, which meant it would pull back the full result set, regardless of the search parameters the user set. This was unacceptable, so I looked for another solution.

Second attempt, I removed the search code form the "browse" function and have it post to a "search" function. The search function push the database record ids for that search into a session variable, which then redirected to the "browse" function, which looked for that session key/value and displayed those particular records. This worked perfectly with everything. When they move off the page (not just details page), I cleared the session search results keys, so when they would come back, they would get the full result set.

BUT, and now it's a big but, because the search does a postback to another page, all the fields are missing the search criteria data when it's redirected back to the "browse" page (the one with all the search fields), so the user would have to re-input all their search parameters (12-15 fields). This doesn't seem like an elegant solution either.

Any ideas of a better way to do handle this?