1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
|
<?php
function pagination($url,$parpage,$nblignes,$nbpages)
{$html = precedent($url,$parpage,$nblignes);
if ($nbpages > 1) {
for ($i = 0 ; $i < $nbpages ; ++$i) {
$ref = $i * $parpage;
$ref = $ref.",".$parpage;
$html .= "<a href=".$url.$ref.">".($i + 1)."</a>";}}
else {$html .= "";}
$html .= suivant($url,$parpage,$nblignes);
return $html;}
function validlimit($nblignes,$parpage,$sql)
{if (isset($_GET['ref'])) {
$pointer = split('[,]', $_GET['ref']);
$debut = $pointer[0];
$fin = $pointer[1];
if (($debut >= 0) && ($debut < $nblignes) && ($fin == $parpage)){
$ref = $_GET['ref'];
$sql .= " LIMIT ".$ref.";";
$result = mysql_query($sql);}
else {$sql .= " LIMIT 0,".$parpage.";";$result = mysql_query($sql);}}
else {$sql .= " LIMIT 0,".$parpage.";";$result = mysql_query($sql);}
return $result;}
function precedent($url,$parpage,$nblignes)
{if ($nblignes > $parpage) {
if (isset($_GET['ref'])) {
$pointer = split('[,]', $_GET['ref']);
$pointer = $pointer[0]-$parpage;
if ($pointer < 0) {$precedent = "";}
else {$ref = "$pointer,$parpage";
$precedent = "<a href=".$url.$ref."><img src='fleche_gauche.gif'></a>";}
}else {$precedent = "";}
}else {$precedent = "";}return $precedent;}
function suivant($url,$parpage,$nblignes)
{if ($nblignes > $parpage) {
if (isset($_GET['ref'])) {
$pointer = split('[,]', $_GET['ref']);
$pointer = $pointer[0] + $parpage;
if ($pointer >= $nblignes) {
$suivant = "";
}else {
$ref = "$pointer,$parpage";
$suivant = "<a class='pagination' href=".$url.$ref."><img src='fleche_droite.gif'></a>";}}
if (@$_GET['ref']== false) {
$suivant = "<a href=".$url.$parpage.",".$parpage."><img src='fleche_droite.gif'></a>";}}
else {$suivant = "";}return $suivant;}
?> |
Partager