Home > Backend Development > PHP Tutorial > PHP imitation discuz pagination effect code_PHP tutorial

PHP imitation discuz pagination effect code_PHP tutorial

WBOY
Release: 2016-07-21 15:49:45
Original
850 people have browsed it

复制代码 代码如下:

/**
* Display style 2
*/
function multi($mpurl,$page = 10) {

$multipage = '';
$mpurl .= strpos($mpurl, '?') ? '&' : '?';
$realpages = 1;
if($this->infocount > $this->items) {
$offset = 2;

$realpages = @ceil($this->infocount / $this->items);
$pages = $this->maxpages && $this->maxpages < $realpages ? $this->maxpages : $realpages;

if($page > $pages) {
$from = 1;
$to = $pages;
} else {
$from = $this->pageno - $offset;
$to = $from + $page - 1;
if($from < 1) {
$to = $this->pageno + 1 - $from;
$from = 1;
if($to - $from < $page) {
$to = $page;
}
} elseif($to > $pages) {
$from = $pages - $page + 1;
$to = $pages;
}
}

$multipage = ($this->pageno - $offset > 1 && $pages > $page ? '1 ...' : '').
($this->pageno > 1 ? '<<' : '');
for($i = $from; $i <= $to; $i++) {
$multipage .= $i == $this->pageno ? ''.$i.'' :''.$i.'';
}

$multipage .= ($this->pageno < $pages ? '>>' : '').
($to < $pages ? '... '.$realpages.'' : '').
($pages > $page ? '' : '');

$multipage = $multipage ? '' : '';
}
return $multipage;
}

这是效果:
图片附件:
大小: 2.07 K
尺寸: 191 x 33
浏览: 28 次
点击打开新窗口浏览全图

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/319496.htmlTechArticle复制代码 代码如下: /*** Display style 2*/ function multi($mpurl,$page = 10) { $multipage = ''; $mpurl .= strpos($mpurl, '?') ? ' $realpages = 1; if($this-infocount $this-it...
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