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: [Jason] pagination on search results

By 4cdg - March 3, 2011

i have attached search.php and searchResults.php

you can see them at www.prosalvage.com/search.php
Attachments:

search_006.php 14K

searchresults.php 14K

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 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