Navigatie met nummering en vorige volgende
Auteur: Slipie - 14 september 2004 - 23:05 - Gekeurd door: Dennisvb - Hits: 11815 - Aantal punten: 3.30 (5 stemmen)
Naja verander de aangegeven gegevens en je komt wer wel
|
Code: |
<?
$page = (!isset($_GET['page'])) ? 1 : $_GET['page'];
//aantal records per pagina
$max = 20;
$start = ($max * $page) - $max;
//hier je gegevens van je mysql ophalen
while($var = mysql_fetch_array(mysql_query("SELECT * FROM table ORDER BY id LIMIT " . $start . ", " . $max . ""))) {
echo $var['id'];
}
//hier aan jou mysql gegevens aanpassen
$rows = mysql_result(mysql_query("SELECT COUNT(id) FROM computers ORDER BY id"),0);
$pages = ceil($rows / $max);
if ($page > 1) {
$previous = $page - 1;
echo "<a href=\"" . $_SERVER['PHP_SELF'] . "?page=" . $previous . "\"><<</a> ";
}
for ($i = 1; $i <= $pages; $i++) {
if ($page == $i) {
if ($i == $pages) {
echo "<b>" . $i . "</b> ";
} else {
echo "<b>" . $i . "</b>, ";
}
} else {
if ($i == $pages) {
echo "<a href=\"" . $_SERVER['PHP_SELF'] . "?page=" . $i . "\">" . $i . "</a> ";
} else {
echo "<a href=\"" . $_SERVER['PHP_SELF'] . "?page=" . $i . "\">" . $i . "</a>, ";
}
}
}
if ($page < $pages) {
$next = $page + 1;
echo "<a href=\"" . $_SERVER['PHP_SELF'] . "?page=" . $next . "\">>></a>";
}
?>
<? $page = (!isset($_GET['page'])) ? 1 : $_GET['page']; //aantal records per pagina $max = 20; $start = ($max * $page) - $max; //hier je gegevens van je mysql ophalen } //hier aan jou mysql gegevens aanpassen $pages = ceil($rows / $max); if ($page > 1) { $previous = $page - 1; echo "<a href=\"" . $_SERVER['PHP_SELF'] . "?page=" . $previous . "\"><<</a> "; } for ($i = 1; $i <= $pages; $i++) { if ($page == $i) { if ($i == $pages) { echo "<b>" . $i . "</b> "; } else { echo "<b>" . $i . "</b>, "; } } else { if ($i == $pages) { echo "<a href=\"" . $_SERVER['PHP_SELF'] . "?page=" . $i . "\">" . $i . "</a> "; } else { echo "<a href=\"" . $_SERVER['PHP_SELF'] . "?page=" . $i . "\">" . $i . "</a>, "; } } } if ($page < $pages) { $next = $page + 1; echo "<a href=\"" . $_SERVER['PHP_SELF'] . "?page=" . $next . "\">>></a>"; } ?>
Download code (.txt)
|
|
Stemmen |
Niet ingelogd. |
|