<html>
<head>
<title>Pagination Test</title>
</head>
<body>
<?php
if (isset($_POST['start'])) // this will work even with POST
$start = $_POST['start']);
else
$start = 0;
$end = $start + 20;
$result = mysql_query('SELECT * FROM table LIMIT ' . $start . ', ' . $end . ';');
for ($i = 0; $i < mysql_num_rows($result); $i++)
{
$row = mysql_fetch_assoc($result);
// print it however you want
}
?>
<form>
<!--
hack to make this work through POST:
for each POST variable you need to keep:
<input type="hidden" name="varname" value="<?php echo $varname; ?>">
-->
<input type="hidden" name="start" value="<?php echo ($start - 20); ?>
<input type="submit" value="Previous page">
</form>
<form>
<!--
hack to make this work through POST:
for each POST variable you need to keep:
<input type="hidden" name="varname" value="<?php echo $varname; ?>">
-->
<input type="hidden" name="start" value="<?php echo ($start + 20); ?>
<input type="submit" value="Next page">
</form>
</body>