pagination

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply
thapelo83
Forum Newbie
Posts: 1
Joined: Wed Apr 18, 2012 2:30 am

pagination

Post by thapelo83 »

Hi all,

i have implemented php pagination to my work..it works fine, BUT only when i have NO CONDITIONS to my if-statements; in other words the problem arises when i click on the NEXT or BACK button; the sql being executed after clicking these buttons is the initial sql; i.e the sql outside of the if-statement

the following code is a sample:

if($_SERVER['REQUEST_METHOD'] == "POST")
{
$clinicName = $_POST['clinic'];
$fromDate = $_POST['fromDate'];
$toDate = $_POST['toDate'];
}

require("initialVariables.php"); //INITIAL SQL

if($clinicName == "IDCC" AND ($fromDate == "" AND $toDate == ""))
{
require("allIDCC.php"); //CONDITION SQL
}
User avatar
Robert07
Forum Contributor
Posts: 113
Joined: Tue Jun 17, 2008 1:41 pm

Re: pagination

Post by Robert07 »

The trick with filtered pagination is that you need to keep track of your filters when you go to the next page. It looks to me like your filters are sent in the $_POST array, which is fine if someone submits a form every time but for pagination you are probably clicking links instead of submit buttons. What you'll need to do is save your filters in either session variables, $_GET parameters (passed in the URL), or cookies. That way they'll still be there when you add a limit to your query by going to the next or previous pages.
Post Reply