ThinkPHP5.1數據分頁輸出
public function test2()
{
//$data=Pzq_article::all();//獲取所有
//$data=Db::table(‘pzq_article‘)->select();
//獲取5條分頁數據
$data=Pzq_article::paginate(5);
//$data=Db::table(‘pzq_article‘)->paginate(5);
$this->view->assign(‘data‘,$data);
return $this->view->fetch();
}
---------------------
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>{$title|default=‘默認標題‘}</title>
<link rel="stylesheet" href="/static/css/bootstrap.min.css">
<script src="/static/js/jquery-3.3.1.min.js"></script>
<script src="/static/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<div class="row">
<div class=‘col-md-2‘></div>
<div class=‘col-md-8‘>
<h2 class="text-center">學生信息</h2>
<table class="table table-default table-bordered table-hover text-center">
<tr class="bg-primary">
<td>ID</td>
<td>類別ID</td>
<td>標題</td>
<td>時間</td>
</tr>
{volist name=‘data‘ id=‘list‘}
<tr>
<td>{$list.id}</td>
<td>
{if $list.cat_id==3}
<span style="color:red">旗艦店</span>
{else/}
{$list.cat_id}
{/if}
</td>
<td>{$list.title}</td>
<td>{$list.add_time|date=‘Y-m-d‘}</td>
</tr>
{/volist}
</table>
</div>
<div class=‘col-md-2‘></div>
<div class="text-center">分頁:{$data|raw}</div>
</div>
</div>
</body>
</html>
ThinkPHP5.1數據分頁輸出