Home >Backend Development >PHP Tutorial >poweredbydiscuz php paging function multi discuz
Copy the code The code is as follows:
/*
* Paging function
* $num is the total number of items, $perpage is the number of items on one page, $curpage is the current page, $mpurl url, $page = 10 shows how many Pagination
*
*/
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 < 1) {
$form = 1;
//$to = $curpage + 1 - $ form;
if ($to - $form < $page) {
$to = $page;
}
}
}
$multipage = ($curpage > 1 ? 'up ' : '');
for ($i = $form; $i <= $to; $i++) {
$multipage .= $i == $curpage ? ''.$i.' ' :
''.$i.' ';
}
$multipage .= $curpage < $realpages ? 'next ' : '';
$multipage = $multipage ? '
The above introduces the poweredbydiscuz PHP paging function multi discuz, including the content of poweredbydiscuz. I hope it will be helpful to friends who are interested in PHP tutorials.