Hey Installer,
The code i've gives the problem i'm experiencing. I haven't included the db code coz it has no bearing on the problem. all i'm doing is passing a function (printPageNumbers) a parameter for the number of rows that are supposed to be returned from the database.This function writes out all the page numbers.
The problem is whenever i go from one page to the next, the variable $current_index always starts at null.
******************************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']}?page=$k'>$k</a> ";
} // end for
print "<br>";
}
?>
</body>
</html>
******************************PHP**************************