用户信息分页显示

原创 2019-01-15 09:45:37 231
摘要:{load href="/static/bootstrap/css/bootstrap.css"}<div class="container"> <div class="row"> <h3 class="text-center">员工信息登记表</h3> <di
{load href="/static/bootstrap/css/bootstrap.css"}
<div class="container">
<div class="row">
<h3 class="text-center">员工信息登记表</h3>
<div class="col-md-8 col-md-offset-2">
<table class="table table-bordered table-hover text-center">
<tr class="info">
<td>ID</td>
<td>姓名</td>
<td>性别</td>
<td>年龄</td>
<td>工资</td>
</tr>
{volist name="staffs" id="staff" }

<tr><td>{$staff.staff_id}</td>
<td>{$staff.name}</td>
<td>{$staff.sex}</td>
<td>{//$staff.age}
{in name="staff.sex" value="0,1"}
{if $staff.sex == 0}
男
{else /}
女
{/if}
{/in}
</td>
<td>{$staff.salary}</td>
</tr>
  {/volist}
</table>
<div class="text-center">{$page|raw}</div>
</div>
</div>

</div>





{load href="/static/jquery/jquery-3.2.1.min.js"}
{load href="/static/bootstrap/js/bootstrap.js"}
<?php 
namespace app\index\controller;
use think\Controller;
use app\index\model\Staff as StaffModel;

class Staff extends Controller
{
//循环标签
public function demo1()
{
$staffs = StaffModel::all(function($query){
$query->field(['staff_id','name,sex','age','salary']);
// ->where('salary','<',100);
});

$this->view->assign('staffs',$staffs);
return $this->view->fetch();
}

public function demo2()
{
//分页配置
$config = [
'type' =>'bootstrap',
'var_page' =>'page'
];

$num =3;
$simple =false;

$paginate = StaffModel::paginate($num,$simple,$config);
$page = $paginate->render();

$this->view->assign('staffs',$paginate);

$this->view->assign('page',$page);

return $this->view->fetch();
}

}


批改老师:查无此人批改时间:2019-01-15 09:59:24
老师总结:嗯,完成的不错。代码要缩进,多加点注释。。继续加油。

发布手记

热门词条