Forum Moderators: coopster

Message Too Old, No Replies

pagination previous and next links to retrieve from form

losing original search criteria

         

Simplecat

1:26 pm on Sep 1, 2005 (gmt 0)



Hi

I have been having trouble using pagination to display user searches from a form. The user can enter search parameters with the following three criteria: pricerange, location and property_type from drop down menu's on a html page. when submitted these are sent to a php page. The first page of results is OK, showing the required results, but when using the next and previoius links the results seem to be unfiltered. Seems that the pagination script loses the original search criteria. and just scrolls through the table. I know the script is basically OK

Could anyone tell me if the below code snippet used for printing out the previous link would rectify this

if($page > 1){
$prev = ($page - 1);

echo '<a href="'.$_SERVER['PHP_SELF'].'?page=' .$prev. '&pricerange='.$_GET['pricerange'].'&location='.$_GET['location'].'&property_type='.$_GET['property_type'].'">prev</a>';

}

Am getting desparate now... this pagination thing is a bugger

Cheers

Simplecat

Aleister

2:13 pm on Sep 1, 2005 (gmt 0)

10+ Year Member



Without knowing what the rest of your code looks like, that line looks fine.

I would make sure that the parameters are getting passed properly first off, and if you are pulling the data out of a database, are you using LIMIT to get specific data (based on the page number)?

I recently implemented something similar on a site I have. I did basically the same thing, although I was using rewrites, so my links were in the format:

/results/topic/2/

which meant:

results.php?t=topic&p=2

The important thing is making sure you pass all of the values you need back to the script.