Pagination where POST is critcal

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
LiveFree
Forum Contributor
Posts: 258
Joined: Tue Dec 06, 2005 5:34 pm
Location: W-Town

Pagination where POST is critcal

Post by LiveFree »

Hello All!

Say I have a musical rating/search system and based on how many 'hits' (matches with the searched text vs the database), that decides wherether or not it will be displayed.

The problem is, I need to paginate this page but I cant just use $_GET because the $_POST info from the Search form still needs to be available.

Any suggestions on how to paginate and still keep the POST data?

Thanks!

*My god its hot here, even in Boston!*
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

Store the POST data in a session
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

My usual, run a query for all the records and use the start and limit from paging in your for loop. You are probably going to need to session or database the input though (like Pimptastic said) to keep it moving like what you want since what is displayed will be dictated by the user.
HubGoblin
Forum Newbie
Posts: 7
Joined: Fri Apr 14, 2006 9:27 am

Post by HubGoblin »

use SESSIONS
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Re: Pagination where POST is critcal

Post by timvw »

There are a couple of options:

- store the posted data in a form on the paginated page (and make sure the pagination links submit the form... thus use buttons instead of hyperlinks to do the navigation)
- append the posted data to the urls

- use sessions (which is an optimised version of the two options mentionned above)
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Post by Benjamin »

You may be able to use POST and GET at the same time depending on your design..

Code: Select all


<form name="example" method="POST" action="yourPage.php?page=3&this=that?">
    <input ... />
</form>

LiveFree
Forum Contributor
Posts: 258
Joined: Tue Dec 06, 2005 5:34 pm
Location: W-Town

Post by LiveFree »

So Many Ideas!

I've decided to test out using hidden fields on my page. And the links generated by a for would have the onclick="form.submit()" event attrib.

Thanks Everyone! :)
Post Reply