TP5数据查询寻,分页展示

PHP:

<?php
namespace app\index\controller;
use think\Controller;
use think\View;
use think\Request;
use think\Db;
class Index extends Controller
{
    public function  datalist(){
    	//分页查询,每页两条数据
    	$data = Db::table("users")->paginate(2);
    	$this->assign('data',$data);
    	//var_dump($data);die;
    	return $this->fetch();
    }
}  

HTML:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Wanna tell her - interactive DHTML</title>
<meta http-equiv="imagetoolbar" content="no">
<style type="text/css">
</style>
<!-- 最新版本的 Bootstrap 核心 CSS 文件 -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">

</head>
<body>
  <table class="table table-condensed">
  <caption>哈哈哈哈</caption>
  <thead>
    <tr>
      <th>ID</th>
      <th>名字</th>
      <th>姓氏</th></tr>
  </thead>
  <tbody>
    <!-- <volist name="data" id="a"> -->
    {volist name="data" id="a"}
    <tr>
      <td>{$a.id}</td>
      <td>{$a.name}</td>
      <td>{$a.xing}</td>
    </tr>
<!--   </volist> -->
  {/volist}
  </tbody>
</table>
{$data->render()}
</body>
</html>

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

微信扫一扫

微信扫一扫

微信扫一扫,分享到朋友圈

TP5数据查询寻,分页展示