标签:this table utf-8 遍历 rom .class 图层 ble lis
1 控制器(application/home/controller/Home.php)
namespace app\home\controller;
use think\Controller;
use think\Db;
class Home extends Controller
{
public function student()
{
$data=Db::query(‘select * from student‘);
$this->assign(‘data‘,$data);
$num=‘aaaaa‘;
$this->assign(‘num‘,$num);
return $this->fetch();
}
}
2 视图层(放在application/home/view/home/student.html)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>页面赋值</title>
</head>
<body>
<table style="border: 1px solid red">
<tr >
<td>姓名</td>
<td>学号</td>
<td>性别</td>
<td>班级</td>
<td>身份</td>
<td>生日</td>
<td>联系方式</td>
</tr>
<!--volist循环遍历 name 控制器传值的key,标志, value获取的值-->
{volist name=‘data‘ id=‘value‘}
<tr>
<!--{{$value.name}} 值里面包含的字段-->
<td>{$value.name}</td>
<td>{$value.studentid}</td>
<td>{$value.sex}</td>
<td>{$value.class}</td>
<td>{$value.polity}</td>
<td>{$value.birthday}</td>
<td>{$value.birthday}</td>
</tr>
{/volist}
</table>
<h2>{$num}</h2> //单个数据赋值
</body>
</html>
标签:this table utf-8 遍历 rom .class 图层 ble lis
原文地址:https://www.cnblogs.com/wancheng0327/p/10337374.html