PHP ver gevorderde |
|
Ik gebruik dit script voor me meberlist.php , helaas wilt het niet werken...
http://www.site...amp;id=249
<?
$number = (!isset($_GET['number'])) ? 1 : $_GET['number'];
//aantal records per pagina
$max = 30;
$start = ($max * $number) - $max;
//hier je gegevens van je mysql ophalen
while($var = mysql_fetch_array(mysql_query("SELECT id,username,race,country,goldcoinstake FROM `members` WHERE active='1' ORDER BY id LIMIT " . $start . ", " . $max . ""))) {
echo $var['id'];
}
//hier aan jou mysql gegevens aanpassen
$rows = mysql_result(mysql_query("SELECT COUNT(id) FROM members WHERE active='1' ORDER BY id"),0);
$pages = ceil($rows / $max);
if ($number > 1) {
$previous = $number - 1;
echo "<a href=\"" . $_SERVER['PHP_SELF'] . "index.php?page=memberlist.php&number=" . $previous . "\"><<</a> ";
}
for ($i = 1; $i <= $pages; $i++) {
if ($number == $i) {
if ($i == $pages) {
echo "<b>" . $i . "</b> ";
} else {
echo "<b>" . $i . "</b>, ";
}
} else {
if ($i == $pages) {
echo "<a href=\"" . $_SERVER['PHP_SELF'] . "index.php?page=memberlist.php&number=" . $i . "\">" . $i . "</a> ";
} else {
echo "<a href=\"" . $_SERVER['PHP_SELF'] . "index.php?page=memberlist.php&number=" . $i . "\">" . $i . "</a>, ";
}
}
}
if ($number < $pages) {
$next = $number + 1;
echo "<a href=\"" . $_SERVER['PHP_SELF'] . "index.php?page=memberlist.php&number=" . $next . "\">>></a>";
}
?>
<? $number = (!isset($_GET['number'])) ? 1 : $_GET['number']; //aantal records per pagina $max = 30; $start = ($max * $number) - $max; //hier je gegevens van je mysql ophalen while($var = mysql_fetch_array(mysql_query("SELECT id,username,race,country,goldcoinstake FROM `members` WHERE active='1' ORDER BY id LIMIT " . $start . ", " . $max . ""))) { } //hier aan jou mysql gegevens aanpassen $pages = ceil($rows / $max); if ($number > 1) { $previous = $number - 1; echo "<a href=\"" . $_SERVER['PHP_SELF'] . "index.php?page=memberlist.php&number=" . $previous . "\"><<</a> "; } for ($i = 1; $i <= $pages; $i++) { if ($number == $i) { if ($i == $pages) { echo "<b>" . $i . "</b> "; } else { echo "<b>" . $i . "</b>, "; } } else { if ($i == $pages) { echo "<a href=\"" . $_SERVER['PHP_SELF'] . "index.php?page=memberlist.php&number=" . $i . "\">" . $i . "</a> "; } else { echo "<a href=\"" . $_SERVER['PHP_SELF'] . "index.php?page=memberlist.php&number=" . $i . "\">" . $i . "</a>, "; } } } if ($number < $pages) { $next = $number + 1; echo "<a href=\"" . $_SERVER['PHP_SELF'] . "index.php?page=memberlist.php&number=" . $next . "\">>></a>"; } ?>
Als ik het goed had, zou die tog de id's moeten geven ? 1, 2 en 3 ofzow ...?
De pagina navigatie werkt volgens mij wel,... alleen niet ... op regel 8 zeg ik tog, dat hij die id's moet weergeven?
|