PDA

View Full Version : How to reset paging after new search


salzbermat
12-16-2004, 08:28 AM
When I go to the search page, enter a search term with many results, go to the second page, then enter a new search term with only very few results (that would show on one page only) I get an empty page showing results "21 - 1" and a back button. I.e. the limit is not reset after the new search. Strangely enough, the search form does not contain limit information and there is no get variable attached to the URL. I have a customized search page that stores GET variables as session vars. Is that where the script "remembers" the paging info?

Thanks for any insights on that.
Bernd

Charter
12-16-2004, 10:04 AM
Are you able to reproduce this on the online demo (http://www.phpdig.net/demo/search.php)? I tried the online demo like this: a) search for phpdig b) click next c) search for hamlet but I didn't see anything peculiar.

salzbermat
12-16-2004, 10:22 AM
Salut Charter,

thanks for the speedy response (again!).

As I thought the problem was that we use a script that turns GET variables to session variables, so $lim_start is already set to the value from the last search result display.

In order to resolve this, I changed in search_functions.php the following line:
if (isset($limit_start)) { $limit_start = $limite * floor($limit_start / $limite); }

to:

if (isset($_GET['lim_start'])) { $limit_start = $limite * floor($_GET['lim_start'] / $limite); } else { $limite=0; $lim_start=0; $limit_start=0; }

Now I'm not sure whether this makes sense in all scenarios, but it works here.