PHP paging function multi() discuz_PHP tutorial

WBOY
Release: 2016-07-21 15:46:26
Original
1191 people have browsed it

Copy code The code is as follows:

/*
* paging function
* $num total number of items, $perpage one How many pages, $curpage current page, $mpurl url, $page = 10 display several pages
*
*/
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 ? '
'.$multipage.'
' : '';
}

return $multipage;
}

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/320168.htmlTechArticleCopy code The code is as follows: /* * Paging function* $num is the total number of items, $perpage is the number of items on a page, $curpage current page, $mpurl url, $page = 10 display several pages* */ function multi($num, $per...
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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template