By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,548 Members | 1,076 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,548 IT Pros & Developers. It's quick & easy.

POST/SESSION variables and pagination

Unicron
P: 8
Hi folks, I have been working on a property listing search for a company for a while now and have hit a roadblock. I have searched the net up and down. A lot of Google results lead to this site, but I have never been able to get it to work.

Here's the setup-

The user submits search criteria via POST. The results php page pulls the $_POST array and displays the results with pagination of 20 results per page with links for Next/Previous.

Clicking on the pagination links loses the variables, whether I simply used $_POST or whether I coded, for instance, $_SESSION['county'] = $_POST['county']; at the top of the script. I, of course, am using session_start(); at the top of the scripts. I have tried all manner of responses regarding sessions,globals,php.ini, and anything else.

The pagination links uses a query string that refers to PHP_SELF and looks like
"http://localhost/advancedsearch.php?offset=21"
where the offset is the 2nd page of 20 results.


Does anyone have any ideas?
Apr 16 '07 #1
Share this Question
Share on Google+
3 Replies


code green
Expert 100+
P: 1,726
Clicking on the pagination links loses the variables, whether I simply used $_POST or whether I coded, for instance, $_SESSION['county'] = $_POST['county']; at the top of the script
Using a hypelink does not generate the POST array .This is only generated from a form. You need to pass the variables as URL variables or as SESSION variables
Apr 17 '07 #2

Unicron
P: 8
Thanks for the response! I knew I had to use session variables, but it just wasn't working. Apparently I missed something, because I put this code in and now everything works great-

foreach($_POST as $k => $v)
{
$_SESSION[$k] = $v;
}

The strange thing is, I used this before and it didn't work. I must have mucked it up elsewhere. Thanks though! It works.
Apr 17 '07 #3

P: 1
session_start();

if (! isset session [query])
{build up query using your post variables;
assign / set a session[query];
}

rest of your code (db connection, pagination, echo results, bla bla)
Oct 22 '11 #4

Post your reply

Sign in to post your reply or Sign up for a free account.