我必须做一个照片分页。
<< 上一页 [图片] 下一页 >>
假设实际页面是这样的:www.myWebSite.com/photo.php?id=12
如果我按Next
,然后我会重定向到www.myWebsite.com/photo.php?id=13
,但如果照片id=13
从数据库中删除,我能做什么?
例如:
<?php
require_once '../classes/dataBaseManager/ImageDataBaseManagr.php';
if ( isset ( $_GET ['id'] ) ) {
$id = $_GET ['id'];
/**
* Initialize my data base class.
*/
try {
$dataBase = ImageDataBaseManager::connect();
$select = $dataBase->select( array ( 'id' => $id );
$previous = (int)($select ['id'] - 1);
$next = (int)($select ['id'] + 1);
$photo = $select ['path'];
echo '<a href="http://www.myWebSite.com/photo.php?id='.$previous.'">Previous</a>';
echo '<img src="'.$path.'" />';
echo '<a href="http://www.myWebSite.com/photo.php?id='.$next.'">Previous</a>';
}
catch ( PDOException $e ) {
error_log( $e->getMessage );
return;
}
}
?>
谢谢 :)