PHP gevorderde |
|
een erg omslachtige manier maar het werkt, zal best wel eenvoudiger kunnen maar nu geen tijd om iets simpelers te bedenken dit heb ik uit mijn eigen fotoalbum.
<?php
$last_pic = mysql_result(mysql_query("SELECT MAX(img_id) FROM images WHERE img_cat = '".$_GET['album']."'") ,0);
for ($i = $_GET['pic'] + 1; $i <= $last_pic + 1; $i++) {
$next_query = mysql_query("
SELECT img_id FROM images
WHERE img_id = '".$i."'
AND img_cat = '".$_GET['album']."'
");
if (mysql_num_rows($next_query) == 0) {
$next_id = false;
}
else {
$next_id = $i;
break;
}
}
for ($j = $_GET['pic'] - 1; $j >= 0; $j--) {
$prev_query = mysql_query("
SELECT img_id FROM images
WHERE img_id = '".$j."'
AND img_cat = '".$_GET['album']."'
");
if (mysql_num_rows($prev_query) == 0) {
$prev_id = false;
}
else {
$prev_id = $j;
break;
}
}
$next = ($next_id !== false) ? '<a href="?album='.$_GET['album'].'&pic='.$next_id.'&page='.$_GET['page'].'">'.$lang['link']['next'].'</a>' : $lang['link']['next'];
$prev = ($prev_id !== false) ? '<a href="?album='.$_GET['album'].'&pic='.$prev_id.'&page='.$_GET['page'].'">'.$lang['link']['prev'].'</a>' : $lang['link']['prev'];
?>
<?php for ($i = $_GET['pic'] + 1; $i <= $last_pic + 1; $i++) { SELECT img_id FROM images WHERE img_id = '".$i."' AND img_cat = '".$_GET['album']."' "); $next_id = false; } else { $next_id = $i; break; } } for ($j = $_GET['pic'] - 1; $j >= 0; $j--) { SELECT img_id FROM images WHERE img_id = '".$j."' AND img_cat = '".$_GET['album']."' "); $prev_id = false; } else { $prev_id = $j; break; } } $next = ($next_id !== false) ? '<a href="?album='.$_GET['album'].'&pic='.$next_id.'&page='.$_GET['page'].'">'.$lang['link']['next'].'</a>' : $lang['link']['next']; $prev = ($prev_id !== false) ? '<a href="?album='.$_GET['album'].'&pic='.$prev_id.'&page='.$_GET['page'].'">'.$lang['link']['prev'].'</a>' : $lang['link']['prev']; ?>
|