pagniton.php
Quell Code
<?php
# Dein Array
$meinarray = array('A','B','C','D','E','F','G','H','I','J','K','L',
'M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v'.'w','x','y','z');
# Anzahl Objekte pro Seite
$int_epp = 1;
$int_total = count($meinarray); // totale Anzahl Objekte
$int_ttpages = ceil($int_total/$int_epp); // totale Anzahl Seiten
$int_tpage = isset($_GET['p']) ? (int)$_GET['p'] : 1; // aktuelle Seite
if($int_tpage>$int_ttpages || $int_tpage<1) $int_tpage = 1;
# Seiten-Navigation
$str_pnav = '<div>Seite: ';
if($int_tpage >= 4)
$str_pnav .= '<a href="?p=1">1</a>'; // erste Seite
if($int_tpage >= 2)
$str_pnav .= ' <a href="?p='.($int_tpage-1).'">««</a> '; // 1 zurück
for($a=1; $a<=$int_ttpages; $a++){
if($a == $int_tpage)
$str_pnav .= '<b>'.$a.'</b>'; // wenn diese Seite
elseif($a>$int_tpage-3 && $a<$int_tpage+3)
$str_pnav .= '<a href="?p='.$a.'">'.$a.'</a>'; // wenn andere Seite
if($a<$int_ttpages && $a>$int_tpage-3 && $a<$int_tpage+2)
$str_pnav .= ' · '; // Trenn-Zeichen
}
if($int_tpage <= $int_ttpages-1)
$str_pnav .= ' <a href="?p='.($int_tpage+1).'">»»</a> '; // 1 vor
if($int_tpage <= $int_ttpages-3)
$str_pnav .= '<a href="?p='.$int_ttpages.'">'.$int_ttpages.'</a>'; // letzte Seite
$str_pnav .= '</div>';
echo $str_pnav; // Seiten-Navigation ausgeben
$int_count = 0;
foreach($meinarray as $value){
$int_count++;
if($int_count > ($int_tpage-1)*$int_epp && $int_count <= $int_tpage*$int_epp){
## Hier werden die Daten ausgegeben (enthalten in $value)
## Beispiel: echo $value.'<br />';
}
elseif($int_count <= ($int_tpage-1)*$int_epp)
continue;
elseif($int_count > $int_tpage*$int_epp)
break;
}
echo $str_pnav; // Seiten-Navigation nochmal ausgeben
?>