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
}
pagination
Moderator: General Moderators
Re: pagination
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.