Demo
Tạo 1 file ví dụ anh***.php dán code này vào
Code:
http://giaitri.ws/nghe-thuat-****/
PHP:
<?php
//error_reporting(E_ALL ^ E_NOTICE);
$view = isset($_GET['view']) ? trim($_GET['view']) : FALSE;
if($view){
if(strlen($view) == 1) $oct = '000';
if(strlen($view) == 2) $oct = '00';
if(strlen($view) == 3) $oct = '0';
if(strlen($view) == 4) $oct = '';
//header
for($i = 1; $i<6; ++$i){
?>
<img src="http://img.rentiyishu.org/image/<?php echo "$oct$view/0$i" ?>.jpg"/><br>
<?php }
}else{
$num = 20;
$page = isset($_GET['p']) ? intval(abs($_GET['p'])) : 1;
$start = ($page*$num)-$num;
//header
echo 'Bộ sưu tập Ảnh ****<br>';
for($i = $start; $i<($page*$num); ++$i){
?>
<div class="menu"><a href="?view=<?php echo $i+1 ?>" title="Bộ sưu tập ảnh **** <?php echo $i+1 ?>">Bộ sưu tập Ảnh **** - Album <?php echo $i+1 ?></a></div>
<?php }
echo nav('?p=', 7000, $page, $num);
}
//footer
function nav($url, $total_recorn, $page_blog, $num_page){
$out = '';
$maxpage = ceil($total_recorn/$num_page);
if($page_blog > $maxpage) $page_blog = $maxpage;
$out .= '<div class="p">';
if($page_blog-1 > 1)
$out .= '<span><a href="'.$url.($page_blog-1).'">«</a></span> ';
if($page_blog > 1)
$out .= '<span><a href="'.$url.'1">1</a></span> ';
if($page_blog-4 > 1) $out .= '... ';
if($page_blog-3 > 1)
$out .= '<span><a href="'.$url.($page_blog-3).'">'.($page_blog-3).'</a></span> ';
if($page_blog-2 > 1)
$out .= '<span><a href="'.$url.($page_blog-2).'">'.($page_blog-2).'</a></span> ';
if($page_blog-1 > 1)
$out .= '<span><a href="'.$url.($page_blog-1).'">'.($page_blog-1).'</a></span> ';
$out .= '<span>['.$page_blog.']</span> ';
if($page_blog+1 < $maxpage)
$out .= '<span><a href="'.$url.($page_blog+1).'">'.($page_blog+1).'</a></span> ';
if($page_blog+2 < $maxpage)
$out .= '<span><a href="'.$url.($page_blog+2).'">'.($page_blog+2).'</a></span> ';
if($page_blog+3 < $maxpage)
$out .= '<span><a href="'.$url.($page_blog+3).'">'.($page_blog+3).'</a></span> ';
if($page_blog+4 < $maxpage) $out .= '... ';
if($page_blog < $maxpage)
$out .= '<span><a href="'.$url.$maxpage.'">'.$maxpage.'</a></span> ';
if($page_blog+1 < $maxpage)
$out .= '<span><a href="'.$url.($page_blog+1).'">»</a></span> ';
$out .= '</div>';
return $out;
}