Not so much tutorial than some random code I just wrote to help me with somthing else…
<?php
error_reporting(E_ALL ^ E_NOTICE);
/*
set some vars
*/
$n = 0;
$max = $_GET['max'];
if (isset($_GET['current'])){
$min = $_GET['current'];
}else{
$min = 0;
}
if (!isset($max)){
$max = 10;
}
/*
lets get some data to work with.
fills an array with 1000 items.
*/
$entries = array();
for ($i = 1; $i <= 1000; $i++) {
$entries[$i] = $i;
}
/*
print the current results
*/
foreach($entries as $entry){
if ($n <= ($max-1)){
if (!($n < $min)){
echo $entry;
}
$n++;
}
}
/*
if we are not on first page of results
show a back button
*/
if ($n > 10){
echo "<br/>";
$min = $n-20;
$bmax = $max - 10;
echo '<a href="?current=' . $min . '&max=' . $bmax . '">Previous</a>';
}
/*
print link to get next ten entries
*/
echo "<br/>";
$max = $max + 10;
echo '<a href="?current=' . $n . '&max=' . $max . '">Next</a>';
?>