Reply
Pagination Using $_POST variables
Old 06-29-2008, 02:52 PM Pagination Using $_POST variables
Average Talker

Posts: 19
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=\"&lt;&lt;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 &gt;&gt;\">";
}
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?
__________________
Website:
http://www.taigawebmasters.com/
ffsja is offline
Reply With Quote
View Public Profile Visit ffsja's homepage!
 
When You Register, These Ads Go Away!
Reply     « Reply to Pagination Using $_POST variables
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.11689 seconds with 12 queries