返回用户信息数据表......登陆

用户信息数据表完成分页显示

҈果҈果҈果҈ ҈ ҈2019-06-28 01:04:24130
<?php
/**
 * Created by PhpStorm.
 * User: 普通用户
 * Date: 2019/6/18
 * Time: 22:27
 */

namespace app\index\controller;
use think\Controller;
use app\index\model\User as UserModel;

class User extends Controller
{
    public  function instance(UserModel $user)
    {
        dump($user->get(1));
    }

    public function demo1()
    {
        $user = UserModel::all(function($query){
            $query->field(['uid','name','phone','country','birthday','weight','height','add_time']);
        });
        $this->view->assign('user',$user);
        return $this->view->fetch();
    }

    public function page()
    {
        $num = 6;
        $isimple = false;
        $config=[
          'type'=>'bootstrap',
          'var_page'=>'page'
        ];

        $user = UserModel::paginate($num,$isimple,$config);

        $page=$user->render();

        $this->view->assign('user',$user);
        $this->view->assign('page',$page);
        return $this->view->fetch();
    }
}
{load href="/static/bootstrap/css/bootstrap.css"/}
<div class="content">
    <div class="row">
        <h2 class="text-center">人员信息登记表</h2>
        <div class="col-md-8 col-md-offset-2">

            <table class="table table-bordered table-hover text-center">
                <tr>
                    <td>工号</td>
                    <td>姓名</td>
                    <td>联系电话</td>
                    <td>国籍</td>
                    <td>生日</td>
                    <td>体重</td>
                    <td>身高</td>
                    <td>入职日期</td>
                </tr>
                {volist name="user" id="use"}
                <tr>
                    <td>{$use.uid}</td>
                    <td>{$use.name}</td>
                    <td>{$use.phone}</td>
                    <td>{$use.country}</td>
                    <td>{$use.birthday}</td>
                    <td>{$use.weight}</td>
                    <td>{$use.height}</td>
                    <td>{$use.add_time}</td>
                </tr>
                {/volist}
            </table>
            <div class="text-center">{$page|raw}</div>
        </div>
    </div>
</div>
{load href="/static/jquery/jquery.js"}
{load href="/static/bootstrap/js/bootstrap.min.js"}

2019-06-28_005749.jpg

经过相近一个月时间学习本章tp5.1基础对tp5.1基本的mvc操作有了初步掌握,后续再不断深入学习提升,争取运用到工作项目中

最新手记推荐

• 用composer安装thinkphp框架的步骤• 省市区接口说明• 用thinkphp,后台新增栏目• 管理员添加编辑删除• 管理员添加编辑删除

全部回复(0)我要回复

暂无评论~
  • 取消回复发送
  • PHP中文网