search

Home  >  Q&A  >  body text

TP5 Establishing a corporate website and calling the administrator list

1.png

File structure

Controller code

<?php

namespace app\admin\controller;

use app\admin\common\Base;
use think\Request;
use app\admin\model\Admin as AdminModel;
class Admin extends Base{
    //显示管理员首页
    public function index()
    {
        //1.读取admin管理员表的信息
        $admin = AdminModel::get(['username'=> 'admin']);
        //2.将当前管理员的信息赋值给模板
        $this -> view -> assign('admin', $admin);
        //3.渲染模板
        return $this -> view -> fetch('admin_list');
    }
}

Error message

2.png

清雨清雨2659 days ago986

reply all(1)I'll reply

  • 清雨

    清雨2017-09-27 09:11:33

    The problem has been solved. It appears in the database table. When the front-end calls the database list, the lowercase id is used. In the database, the id is Id, so there is a problem.

    reply
    0
  • Cancelreply