paging links by posting conditions

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

User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

The search query is done via post. The landing page provides a search id and pagination through get.
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

feyd wrote:The search query is done via post. The landing page provides a search id and pagination through get.
And then saved via sessions...?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

superdezign wrote:And then saved via sessions...?
Cached in the database for a period of time.
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

That's an approach I haven't heard of before. Not something that would be done (efficiently) on a search engine.
shivam0101
Forum Contributor
Posts: 197
Joined: Sat Jun 09, 2007 12:09 am

Post by shivam0101 »

After using POST method, i am getting the results. Problem starts in the hyper links(first, previous, next, last). How to pass the search condition when i click on these links. The link conditions should not appear in the address bar.
User avatar
nathanr
Forum Contributor
Posts: 200
Joined: Wed Jun 07, 2006 5:46 pm

Post by nathanr »

you could always control all the paging by saving the current paging settings in session.. although why not just leave them in the uri?
shivam0101
Forum Contributor
Posts: 197
Joined: Sat Jun 09, 2007 12:09 am

Post by shivam0101 »

$_SESSION['searchcond']=$_POST['cond'];

and in the each subsequent page i should use,

$condition=$_SESSION['searchcond'];

is that right. (after session_start at the top).
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

That is a way to do it.
shivam0101
Forum Contributor
Posts: 197
Joined: Sat Jun 09, 2007 12:09 am

Post by shivam0101 »

Thanks for helping me to solve this. This is how it was solved.

Code: Select all

<?php

echo '<form method='post'>';

?>
after i post,

Code: Select all

<?php
if($_POST)
$_SESSION['condition']=$_POST;

?>
for the navigation,

Code: Select all

<?php
$num=$_GET['num'];//next page
?>
Post Reply