我创建了一个很好的下一个和上一个图像链接。但我希望他们都循环回到开头或结尾。所以说我有 image101、image 202 和 image243,一旦我点击 image243,它就会回到 image101。
我想和以前一样,当我点击 Image101 时,我希望链接返回到 image243。(自我解释)。
我该怎么做呢?
<?php $sql = "SELECT id FROM albums WHERE user_id=".$user['id']." ORDER BY id ASC LIMIT 1"; $query = mysql_query($sql)or die(mysql_error());
while($album = mysql_fetch_array($query)){ ?>
<?php
$photo_sql = "SELECT photo_id FROM userphotos WHERE photo_id > ".$_GET['pid']." AND photo_ownerid = ".$user['id']." AND album_id=".$album['id']." ORDER BY photo_id ASC LIMIT 1 ";
$photo_query = mysql_query($photo_sql)or die(mysql_error());
$photo_next=mysql_fetch_array($photo_query);
echo "<a href='photo.php?pid=".$photo_next['photo_id']."'>Next</a>";
$photo_sql = "SELECT photo_id FROM userphotos WHERE photo_id < ".$_GET['pid']." AND photo_ownerid = ".$user['id']." AND album_id=".$album['id']." ORDER BY photo_id DESC LIMIT 1 ";
$photo_query = mysql_query($photo_sql)or die(mysql_error());
$photo_prev=mysql_fetch_array($photo_query);
echo " | <a href='photo.php?pid=".$photo_prev['photo_id']."'>Prev</a>";
}
?>