Posted in PHP onOctober 02, 2008
/** * 显示样式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 ? '<a href="'.$mpurl.'page=1" class="first">1 ...</a>' : ''). ($this->pageno > 1 ? '<a href="'.$mpurl.'page='.($this->pageno - 1).'" class="p_redirect"><<</a>' : ''); for($i = $from; $i <= $to; $i++) { $multipage .= $i == $this->pageno ? '<a class="p_curpage"><strong>'.$i.'</strong></a>' :'<a href="'.$mpurl.'page='.$i.'" class="p_num">'.$i.'</a>'; } $multipage .= ($this->pageno < $pages ? '<a href="'.$mpurl.'page='.($this->pageno + 1).'" class="p_redirect">>></a>' : ''). ($to < $pages ? '<a href="'.$mpurl.'page='.$pages.'" class="last">... '.$realpages.'</a>' : ''). ($pages > $page ? '<kbd><input type="text" name="custompage" size="3" onkeydown="if(event.keyCode==13) {window.location=\''.$mpurl.'page=\'+this.value; return false;}" /></kbd>' : ''); $multipage = $multipage ? '<div class="p_bar"><a class="p_total"> '.$this->infocount.' </a><a class="p_pages"> '.$this->pageno.'/'.$pages.' </a>'.$multipage.'</div>' : ''; } return $multipage; }
这是效果:
图片附件:
php仿discuz分页效果代码
声明:登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述。
Reply on: @reply_date@
@reply_contents@