view plain
//新的分页函数
function fenye($fenyeurl,$page,$totalnum,$perpage,$rewrite=0){
$page = max($page,1);
$totalpage = ceil($totalnum/$perpage);
$rangepage = 6;
$startpage = max(1,$page – $rangepage);
$endpage = min($totalpage,$startpage+$rangepage*2 – 1);
$startpage = min($startpage,$endpage – $rangepage*2 + 1);
if($startpage < 1) $startpage = 1; $fileext = $rewrite ? '.html':'';
$html = ”;
$html .= ‘首页’;
$html .= $page > 1 ? ‘上一页’:”;
for($i = $startpage;$i <= $endpage;$i++){
$html .= ”.$i.”;
if($i == $totalpage) break;
}
$html .= $page < $totalpage ? '下一页':'';
$html .= ‘末页’;
$html .= ”;
return $html;
}
作者“default7”