w3sl3y2003 Posted November 22, 2006 Share Posted November 22, 2006 Hi all,I'm pretty much a noob at php and really need some help if someone is willing and able.I'd like to create a self-processing form that uses pagination to traverse a database resultset. I've basically nailed the cause of the problem that i have down to the fact that when i try to read the value i store in a hidden field, it's always null.I've included just a rough skeleton of what i'm trying to do (without the unnecessary db code), to just simulate the problem. This code has the same problem as my original attempt by the way.**************************PHP*******************************<html><body> <br> <div> Previous news bulletins </div> <br><?php $current_index = $_POST['current_index']; printPageNumbers(262); for($i=0; $i<10; $i++) { print "Current Index = " . $current_index . "<br>"; $current_index++; } print "-------------------------------"; ?> <form name="testform" method="POST" action="<?php echo $_SERVER['PHP_SELF'] ?>"> <input name="current_index" value="<?php print $current_index ?>" type="hidden"> </form><?php function printPageNumbers($num_rows) { $remainder_page_size; $num_pages = (int) ($num_rows / 10); //10 is the number of rows per page if(($num_rows / 10) > (int)($num_rows / 10)) { $remainder_page_size = $num_rows - (int)($num_rows / 10); $num_pages++; } $page = (is_numeric($_GET['page']) && $_GET['page'] > 0) ? $_GET['page'] : 1; for($k = 0; $k < $num_pages; $k++)//for($k = ($page - 2); $k <= ($page + 2); $k++) { echo ($page == $k) ? "[$k] " : "<a href='{$_SERVER['PHP_SELF']}?option=com_news&ItemId=68&page=$k'>$k</a> "; } // end for print "<br>";// return $page; }?></body></html>**************************PHP*******************************Any and all help is greatly appreciated! Link to comment https://forums.phpfreaks.com/topic/28080-self-processing-pagination/ Share on other sites More sharing options...
JasonLewis Posted November 22, 2006 Share Posted November 22, 2006 so the problem is your not getting a value from the hidden field? if so add a ; to the end of the print function and also in the form action part. Link to comment https://forums.phpfreaks.com/topic/28080-self-processing-pagination/#findComment-128477 Share on other sites More sharing options...
w3sl3y2003 Posted November 22, 2006 Author Share Posted November 22, 2006 Thanks for the helping hand ProjectFear!"so the problem is your not getting a value from the hidden field?" - every time i click on one of the page numbers it the value of $current_index is reset to null.Unfortunately ; didn't make a difference.Any ideas? Link to comment https://forums.phpfreaks.com/topic/28080-self-processing-pagination/#findComment-128512 Share on other sites More sharing options...
JasonLewis Posted November 23, 2006 Share Posted November 23, 2006 by looking at your code your not getting any data from the form because it is not being submitted. the form needs to be submitted to receive data. Link to comment https://forums.phpfreaks.com/topic/28080-self-processing-pagination/#findComment-128991 Share on other sites More sharing options...
w3sl3y2003 Posted November 27, 2006 Author Share Posted November 27, 2006 Thanks ProjectFear!!!! Link to comment https://forums.phpfreaks.com/topic/28080-self-processing-pagination/#findComment-130875 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.