pagination on search results

8 posts by 2 authors in: Forums > CMS Builder
Last Post: June 10, 2011   (RSS)

By 4cdg - March 3, 2011

having a problem. when i send search results from a search form to a results page, the first page works great, then if i go to next page it shows all records.

any suggestions

Re: [4cdg] pagination on search results

By Jason - March 3, 2011

Hi,

If you could attach the .php file you're working with and provide a url to an example, I can take a closer look for you.

Thanks
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [4cdg] pagination on search results

By Jason - March 7, 2011

Hi,

I haven't been able to recreate your issue. When I do a search for everything, I get two pages. Going to the second page doesn't only displays 3 results. Going back and forth between the two pages doesn't seem to cause an issue either.

Could you give me some more background on exactly what search you're doing when you encounter this problem?

Thanks
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] pagination on search results

By 4cdg - March 7, 2011

i can't duplicate the issue either.... I guess it works. thanks

Re: [4cdg] pagination on search results

By 4cdg - June 10, 2011

I have found the issue, with the pages discussed above. when you perform a search everything is fine until you go to page 2 of the search results, then it displays all the records on page 2. It only does this when i have pagination setup.

If i do a search for price min 15,000 and max 20,000 it returns 2 pages of results. I have is setup to list page 1, page 2 etc along with prev and next. if you click next it holds the search criteria. If you select page 2 it drops all the search criteria and shows all records.

You can view them live at http://www.prosalvage.com there is a quick search and http://www.prosalvage.com/search.php is the other search form. I am able to produce the error from these 2 searches.

I have attached the documents again also.

Re: [4cdg] pagination on search results

By Jason - June 10, 2011

Hi,

The problem you're getting here is that on your individual page links, you're not maintaining your search query, which is why all your results are being displayed.

We can get around this by using some code Chris posted here:

http://www.interactivetools.com/forum/gforum.cgi?post=83903#83903

Using this, we can change our foreach loop to look like this:

<?php foreach (range(1,$vehiclesMetaData['totalPages']) as $page): ?>
<?php if ($page == $current_page): ?>
<span class="pagination"><strong><?php echo $page; ?></strong></span>
<?php else: ?>
<span class="pagination"><strong><a href="?<?php echo http_build_query(array_merge($_REQUEST, array( 'page' => $page ))) ?>"><?php echo $page; ?></a></strong></span>
<?php endif ?>
<?php endforeach; ?>


This will maintain your search options.

Hope this helps
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] pagination on search results

By 4cdg - June 10, 2011

Thanks man, that worked perfectly