- Bootstrap
a) Table 引用了’table-striped’, ‘table-hover’, ‘table-condensed’
b) volist name=”list” id=”vo”
c) 变量值用{$vo.xxxx} 获取标量的值
<div class="container-fluid">
<div class="table-responsive">
<table class="table table-striped table-hover table-condensed">
<thead>
<tr>
<th>
</th>
<th>
用户名
</th>
<th>
密码
</th>
<th>
电话号码
</th>
<th>
电子邮件
</th>
<th>
</th>
<th>
</th>
</tr>
</thead>
<tbody id="tbuser">
<volist name="list" id="vo">
<tr class="myclass">
<td>
<input type="checkbox" name="udCheck"/>
</td>
<td class="vousername">
{$vo.username}
</td>
<td class="vopassword">
{$vo.password}
</td>
<td class="vophone">
{$vo.phone}
</td>
<td class="voemail">
{$vo.email}
</td>
<td>
<a href='#' onclick="deleteUser('{$vo.userName}',this);" class="btn btn-danger btn-sm">删除</a>
</td>
<td>
<a class="edithere" class="btn btn-primary btn-sm" data-toggle="modal" data-target="#example">编辑</a>
</td>
</volist>
</tbody>
</table>
<nav style="text-align:center;">
<ul class="pagination">
{$page}
</ul>
</nav>
</div>
- Thinkphp
thinkphp 用了分页的方式来处理
<?php
?>
$count= $user->count();
$Page = new \Think\Page($count,10);
$Page->setConfig('prev', 'previous page');
$Page->setConfig('next', 'next page');
$Page->setConfig('first', 'First Page');
$Page->setConfig('last', 'End Page');
$Page->setConfig ( 'theme', '当前%NOW_PAGE%/%TOTAL_PAGE%%FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END%' );
$show = $Page->show();
$list = $user->order('uid')->limit($Page->firstRow.','.$Page->listRows)->select();
$this->assign('list',$list);
$this->assign('page',$show);
$this->display("profileau");
<?php
- 修改后的page.class.php
<?php
class Page {
public $rollPage = 5;
public $parameter ;
public $url = '';
public $listRows = 20;
public $firstRow ;
protected $totalPages ;
protected $totalRows ;
protected $nowPage ;
protected $coolPages ;
protected $config = array('header'=>'条记录','prev'=>'上一页','next'=>'下一页','first'=>'第一页','last'=>'最后一页','theme'=>' <span style="font-size:18px; padding-top: 5px;
height: 30px;padding-left: 5px;display: inline-block;">%totalRow% %header% %nowPage%/%totalPage% 页</span> %upPage% %downPage% %first% %prePage% %linkPage% %nextPage% %end%');
protected $varPage;
public function __construct($totalRows,$listRows='',$parameter='',$url='') {
$this->totalRows = $totalRows;
$this->parameter = $parameter;
$this->varPage = C('VAR_PAGE') ? C('VAR_PAGE') : 'p' ;
if(!empty($listRows)) {
$this->listRows = intval($listRows);
}
$this->totalPages = ceil($this->totalRows/$this->listRows);
$this->coolPages = ceil($this->totalPages/$this->rollPage);
$this->nowPage = !empty($_GET[$this->varPage])?intval($_GET[$this->varPage]):1;
if(!empty($this->totalPages) && $this->nowPage>$this->totalPages) {
$this->nowPage = $this->totalPages;
}
$this->firstRow = $this->listRows*($this->nowPage-1);
}
public function setConfig($name,$value) {
if(isset($this->config[$name])) {
$this->config[$name] = $value;
}
}
public function show() {
if(0 == $this->totalRows) return '';
$p = $this->varPage;
$nowCoolPage = ceil($this->nowPage/$this->rollPage);
if($this->url){
$depr = C('URL_PATHINFO_DEPR');
$url = rtrim(U('/'.$this->url,'',false),$depr).$depr.'__PAGE__';
}else{
if($this->parameter && is_string($this->parameter)) {
parse_str($this->parameter,$parameter);
}elseif(empty($this->parameter)){
unset($_GET[C('VAR_URL_PARAMS')]);
if(empty($_GET)) {
$parameter = array();
}else{
$parameter = $_GET;
}
}
$parameter[$p] = '__PAGE__';
$url = U('',$parameter);
}
$upRow = $this->nowPage-1;
$downRow = $this->nowPage+1;
if ($upRow>0){
$upPage = "<li><li><a href='".str_replace('__PAGE__',$upRow,$url)."'>".$this->config['prev']."</a></li></li>";
}else{
$upPage = '';
}
if ($downRow <= $this->totalPages){
$downPage = "<li><li><a href='".str_replace('__PAGE__',$downRow,$url)."'>".$this->config['next']."</a></li></li>";
}else{
$downPage = '';
}
if($nowCoolPage == 1){
$theFirst = '';
$prePage = '';
}else{
$preRow = $this->nowPage-$this->rollPage;
$prePage = "<li><li><a href='".str_replace('__PAGE__',$preRow,$url)."' >上".$this->rollPage."页</a></li></li>";
$theFirst = "<li><a href='".str_replace('__PAGE__',1,$url)."' >".$this->config['first']."</a></li>";
}
if($nowCoolPage == $this->coolPages){
$nextPage = '';
$theEnd = '';
}else{
$nextRow = $this->nowPage+$this->rollPage;
$theEndRow = $this->totalPages;
$nextPage = "<li><a href='".str_replace('__PAGE__',$nextRow,$url)."' >下".$this->rollPage."页</a></li>";
$theEnd = "<li><a href='".str_replace('__PAGE__',$theEndRow,$url)."' >".$this->config['last']."</a></li>";
}
$linkPage = "";
for($i=1;$i<=$this->rollPage;$i++){
$page = ($nowCoolPage-1)*$this->rollPage+$i;
if($page!=$this->nowPage){
if($page<=$this->totalPages){
$linkPage .= " <li><a href='".str_replace('__PAGE__',$page,$url)."'> ".$page." </a></li>";
}else{
break;
}
}else{
if($this->totalPages != 1){
$linkPage .= " <span class='current'>".$page."</span>";
}
}
}
$pageStr = str_replace(
array('%header%','%nowPage%','%totalRow%','%totalPage%','%upPage%','%downPage%','%first%','%prePage%','%linkPage%','%nextPage%','%end%'),
array($this->config['header'],$this->nowPage,$this->totalRows,$this->totalPages,$upPage,$downPage,$theFirst,$prePage,$linkPage,$nextPage,$theEnd),$this->config['theme']);
return $pageStr;
}
}