日期:2014-05-16 浏览次数:20472 次
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<style type="text/css">
a.cur{color:#FFF; background:#176081; font-weight:bold;}
a.btn{color:#333; width:60px;}
a{color:#333; margin:3px; padding:3px; font-size:14px; border:1px solid #dedfe1; text-align:center; text-decoration:none; width:17px; display:block; float:left;}
span{display:block; float:left; font-size:14px; line-height:30px;}
</style>
<?php
$curpage = isset($_GET['curpage'])? $_GET['curpage'] : 1;
$total = 1000;
$pagesize = 20;
$url = 'page.php';
$show = 10;
echo page($curpage, $pagesize, $total, $url, $show);
function page($curpage, $pagesize, $total, $url, $show){
if($total<=0
------解决方案--------------------
$curpage<=0
------解决方案--------------------
$pagesize<=0
------解决方案--------------------
$show<=0){
return '';
}
$pagecount = (int)(($total-1)/$pagesize)+1;
if($curpage>$pagecount){
$curpage = $pagecount;
}
$tmp = '';
$step = (int)($show/2);
if($curpage-$step<=0){
$start = 1;
$end = $pagecount>$show? $show : $pagecount;
}elseif($curpage+$step>=$pagecount){
$start = $pagecount-$show+1;
$end = $pagecount;
}else{
$start = $curpage-$step;
$end = $start+$show-1;
}
if($curpage>1){
&nbs