Hi, I'm using pagination to split up the records returned from a query into pages. I have to pass the variables by $_POST instead of $_GET because there are so many of them. Everything works EXCEPT that when I create my submit buttons (the NEXT and PREV buttons to cycle through the pages) I send both values as $pageno and end up having only the NEXT button work correctly because they are both set to the same variable which they have to be in order to make it work (i think). Since I pass them both as hidden variables is there a way to make a hidden variable only pass if a button is clicked?
Here's some of my code, first I'll start at the top where it gets the variable passed:
Code:
if (isset($_POST['pageno'])) {
$pageno = $_POST['pageno'];
} else {
$pageno = 1;
}
Later on after I've showing the results I show the NEXT and LAST buttons:
Code:
if ($pageno == 1) {
$display_block .= "";
} else {
$prevpage = $pageno-1;
$display_block .= "<input type=\"hidden\" name=\"pageno\" value=\"$prevpage\">";
$display_block .= "<input type=\"submit\" value=\"<<Prev Page\">";
}
$display_block .= " ( Page $pageno of $lastpage ) ";
if ($pageno == $lastpage) {
$display_block .= "";
} else {
$nextpage = $pageno+1;
$display_block .= "<input type=\"hidden\" name=\"pageno\" value=\"$nextpage\">";
$display_block .= "<input type=\"submit\" value=\"Next Page >>\">";
}
As you can see it passes both hidden fields with the value of $nextpage! frustrating! Since I have to use $_POST variables how can I pass the $pageno variable correctly so the NEXT PAGE and LAST PAGE buttons work as intended? anyone?
|