控制器代码
<?php
namespace controller;
class AdminController
{
public $view;
public $model;
public function __construct($model,$view)
{
$this->model = $model;
$this->view = $view;
}
public function index()
{
$admin = $this->model->select('admin',['name','id']);
return $this->view->render('admins/index',['page'=>1,'admin'=>$admin]);
}
}
视图代码
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<table border="1px">
<caption>管理员信息表</caption>
<thead>
<tr>
<th>编号</th>
<th>姓名</th>
<td>操作</td>
</tr>
</thead>
<tbody>
<?php foreach($admin as $value){?>
<tr>
<td><?=$value['id']?></td>
<td><?=$value['name']?></td>
<td>
<button>编辑</button>
<button>删除</button></td>
</tr>
<?php }?>
</tbody>
</table>
</body>
</html>
效果图