tp5 数据查询和分页
1. 新建一个model类
-
namespace app\admin\model;
-
use think\Model;
-
class Admin extends Model{
-
-
}
-
public function lst(){
-
$list = AdminModel::paginate(3);
-
$this->assign('list', $list);
-
return $this->fetch();
-
}
3.将分页查询出来的值调用到页面上
-
<div class="widget-body">
-
<div class="flip-scroll">
-
<table class="table table-bordered table-hover">
-
<thead class="">
-
<tr>
-
<th class="text-center" width="4%">ID</th>
-
<th class="text-center">用户名称</th>
-
<th class="text-center" width="16%">操作</th>
-
</tr>
-
</thead>
-
<tbody>
-
{volist name="list" id="vo"}
-
<tr>
-
<td align="center">{$vo.id}</td>
-
<td align="center">{$vo.username}</td>
-
<td align="center">
-
<a href="/admin/user/edit/id/6.html" class="btn btn-primary btn-sm shiny">
-
<i class="fa fa-edit"></i> 编辑
-
</a>
-
<a href="#" onClick="warning('确实要删除吗', '/admin/user/del/id/6.html')" class="btn btn-danger btn-sm shiny">
-
<i class="fa fa-trash-o"></i> 删除
-
</a>
-
</td>
-
</tr>
-
{/volist}
-
</tbody>
-
</table>
-
</div>
-
<div>
-
{$list->render()}
-
</div>
-
</div>