Welcome Guest, Not a member yet? Register   Sign In
Filtering of results in pagination
#1

[eluser]bertcarremans[/eluser]
Hi,


I am creating a page on which I want to show results from the database using pagination. Secondly I want to allow the user to further filter these results with a few search fields (drop down boxes).

My question now is how can I make sure that when the user clicks on a following page (via the pagination links) that these results are still corresponding to the selection made in the search field?

Should I store the selected value in the URL or in a session variable?

Thanks!
#2

[eluser]Andy Fraley[/eluser]
I just recently had to do this myself. I kept the filter values in the url. I needed more than one filter and sorting, though, so I had to write my own pagination functions as CI's pagination is pretty limited.

My urls look something like:
Code:
site_url('controller/function/' . $pagination_offset . '/'. $sort_col . '/' . $sort_direction . '/' . $filter_col . '/' .  $filter_id)

I handled the result filtering in the database queries so that I could get the correct number of results per page and total results for the pagination with filters. If the filter or sorting changes, the user gets sent back to page one.

If you know your number of results will never be huge, it may be easier to handle this in javascript and just send all of the results to the browser.




Theme © iAndrew 2016 - Forum software by © MyBB