通过 limit,page分页
控制器:
$rel = $member->limit(5)->page($_GET['p'])->select();
$mecount = $member->select();
$Pages = new \Think\Page(count($mecount),5);
$Pages->setConfig('header','<span class="rows">共 %TOTAL_ROW% 位会员</span>');
$Pages->setConfig('prev','上一页');
$Pages->setConfig('next','下一页');
$Pages->setConfig('first','首页');
$Pages->setConfig('last','末页');
$show = $Pages->show();
$this->assign('page', $show);
Page.class.php
将第 33行:
'theme' => '%FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END%',
改为:
'theme' => '%HEADER% %FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END%',
第103行:
if($this->totalPages > $this->rollPage && ($this->nowPage - $now_cool_page) >= 1){
$the_first = '<a class="first" href="' . $this->url(1) . '">' . $this->config['first'] . '</a>';
}
改为:
if(!empty($down_page) || !empty($up_page)){
$the_first = '<a class="first" href="' . $this->url(1) . '">' . $this->config['first'] . '</a>';
}
第108行:
if($this->totalPages > $this->rollPage && ($this->nowPage + $now_cool_page) < $this->totalPages){
$the_end = '<a class="end" href="' . $this->url($this->totalPages) . '">' . $this->config['last'] . '</a>';
}
改为:
if(!empty($down_page) || !empty($up_page)){
$the_end = '<a class="end" href="' . $this->url($this->totalPages) . '">' . $this->config['last'] . '</a>';
}
第92行:
$this->lastSuffix && $this->config['last'] = $this->totalPages;
改为:
$this->lastSuffix = $this->totalPages;
模板:
<div class='page'>{$page}</div>
css样式:
.page{ text-align:center; margin-top:20px; height:30px;}
.page a,.page span{ margin-left:10px;}
.page .num{width:50px;border:1px solid
.current{background: