tp5 数据查询和分页

1.  新建一个model

  1. namespace appadminmodel;
  2. use thinkModel;
  3. class Admin extends Model{
  4.  
  5. }

2. 调用model类进行分页

  1. public function lst(){
  2. $list = AdminModel::paginate(3);
  3. $this->assign('list', $list);
  4. return $this->fetch();
  5. }

3.将分页查询出来的值调用到页面上

    1. <div class="widget-body">
    2. <div class="flip-scroll">
    3. <table class="table table-bordered table-hover">
    4. <thead class="">
    5. <tr>
    6. <th class="text-center" width="4%">ID</th>
    7. <th class="text-center">用户名称</th>
    8. <th class="text-center" width="16%">操作</th>
    9. </tr>
    10. </thead>
    11. <tbody>
    12. {volist name="list" id="vo"}
    13. <tr>
    14. <td align="center">{$vo.id}</td>
    15. <td align="center">{$vo.username}</td>
    16. <td align="center">
    17. <a href="/admin/user/edit/id/6.html" class="btn btn-primary btn-sm shiny">
    18. <i class="fa fa-edit"></i> 编辑
    19. </a>
    20. <a href="#" onClick="warning('确实要删除吗', '/admin/user/del/id/6.html')" class="btn btn-danger btn-sm shiny">
    21. <i class="fa fa-trash-o"></i> 删除
    22. </a>
    23. </td>
    24. </tr>
    25. {/volist}
    26. </tbody>
    27. </table>
    28. </div>
    29. <div>
    30. {$list->render()}
    31. </div>
    32. </div>
原文地址:https://www.cnblogs.com/Y15965521559/p/13696722.html