代码如下:
/**
* 显示样式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 ? '' : '').
($this->pageno > 1 ? '' : '');
for($i = $from; $i <= $to; $i++) {
$multipage .= $i == $this->pageno ? ''.$i.'' :'';
} $multipage .= ($this->pageno < $pages ? '>' : '').
($to < $pages ? '' : '').
($pages > $page ? '' : ''); $multipage = $multipage ? ' ' : '';
}
return $multipage;
}
* 显示样式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 ? '' : '').
($this->pageno > 1 ? '' : '');
for($i = $from; $i <= $to; $i++) {
$multipage .= $i == $this->pageno ? ''.$i.'' :'';
} $multipage .= ($this->pageno < $pages ? '>' : '').
($to < $pages ? '' : '').
($pages > $page ? '' : ''); $multipage = $multipage ? ' ' : '';
}
return $multipage;
}
这是效果:
图片附件:
原文链接:https://www.f2er.com/php/29447.html