Home > php教程 > php手册 > body text

php 分页函数multi() discuz

WBOY
Release: 2016-06-13 12:23:36
Original
831 people have browsed it

复制代码 代码如下:


/*
* 分页函数
* $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 ? '

'.$multipage.'
' : '';
}

return $multipage;
}
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!