php 分页函数multi() discuz
/*
* 分页函数
* $num 总条数,$perpage 一页多少条, $curpage 当前页, $mpurl url, $page = 10 显示几个分页
*
*/
function multi($num, $perpage, $curpage, $mpurl, $page = 10) {
$multipage = '';
$realpages = 1;
if ($num > $perpage){
$offset = 4;
$realpages = @ceil($num / $perpage);
if ($page > $realpages) {
$form = 1;
$to = $realpages;
}else {
$form = $curpage - $offset;
$to = $form + $page - 1;
if ($form $form = 1;
//$to = $curpage + 1 - $form;
if ($to - $form $to = $page;
}
}
}
$multipage = ($curpage > 1 ? 'up ' : '');
for ($i = $form; $i $multipage .= $i == $curpage ? ''.$i.' ' :
''.$i.' ';
}
$multipage .= $curpage next ' : '';
$multipage = $multipage ? '
}
return $multipage;
}
上一篇: 什么是Ajax无刷新技术?
下一篇: PHP安装攻略:PostgreSQL