<?
error_reporting(E_ALL);
if(isset($_GET['p'])){
$_GET['p'] = $_GET['p'];
}else{
$_GET['p'] = 1;
}
$_GET['p'] = $_GET['p']-1;
$pagina = "Dit is pagina 1 [page]
Dit is pagina 2 [page]
Dit is pagina 3 [page]
Dit is pagina 4 [page]
Dit is pagina 5 [page]
Dit is pagina 6 [page]
Dit is pagina 7 [page]
Dit is pagina 8 [page]
Dit is pagina 9 [page]
Dit is pagina 10";
$exp = explode("[page]", $pagina);
$tot = count($exp);
echo "Aantal pagina's: ".$tot."<br />";
echo $exp[$_GET['p']];
echo '<div align="right">';
if($_GET['p'] > 0){
echo '<a href="?p='.($_GET['p']).'" class="link">«</a>';
}
for($i = 1; $i <= $tot; $i++){
if(($_GET['p']+1) == $i){
echo ' <strong>'.$i.'</strong> ';
}
else{
echo '<a href="?p='.$i.'" class="link"> '.$i.' </a>';
}
}
if($_GET['p'] < ($tot-1)){
echo '<a href="?p='.($_GET['p']+2).'" class="link">»</a>';
}
echo '</div>';
?>
<?
$_GET['p'] = $_GET['p'];
}else{
$_GET['p'] = 1;
}
$_GET['p'] = $_GET['p']-1;
$pagina = "Dit is pagina 1 [page]
Dit is pagina 2 [page]
Dit is pagina 3 [page]
Dit is pagina 4 [page]
Dit is pagina 5 [page]
Dit is pagina 6 [page]
Dit is pagina 7 [page]
Dit is pagina 8 [page]
Dit is pagina 9 [page]
Dit is pagina 10";
echo "Aantal pagina's: ".$tot."<br />"; echo '<div align="right">'; if($_GET['p'] > 0){
echo '<a href="?p='.($_GET['p']).'" class="link">«</a>'; }
for($i = 1; $i <= $tot; $i++){
if(($_GET['p']+1) == $i){
echo ' <strong>'.$i.'</strong> '; }
else{
echo '<a href="?p='.$i.'" class="link"> '.$i.' </a>'; }
}
if($_GET['p'] < ($tot-1)){
echo '<a href="?p='.($_GET['p']+2).'" class="link">»</a>'; }
?>