我想创建一个脚本,让您在图像中导航(下一个和上一个)。这是我到目前为止所拥有的,但它不起作用。
桌子:images
排:imageID
row: image_name
=> 这是建立一个链接来查看图像。
$currentid = $row['imageID'];
$query = "SELECT imageID as prev
FROM images WHERE imageID < '$currentid'
ORDER by imageID DESC LIMIT 1;";
$result = mysql_query($query) or die("Unable to read table : $query");
$list = array();
while ($image = mysql_fetch_assoc($result)) {
$list[] = $image["imageID"];
}
$current_item = array_search($id1,$list);
$prev_link = $next_link = "";
if ($current_item > 0) {
// do previous link with $list[$current_item - 1]
}
if ($current_item < sizeof($list)-1) {
// do next link with $list[$current_item + 1]
}