Volist标签主要用于在模板中循环输出数据集或者多维数组。
web页面代码
<!DOCTYPE html> <html> <head> <title></title> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <style type="text/css"> table,tr,td{border: 1px solid gray;text-align: center;} pre{font-size: 16px;} </style> </head> <body> <table> <tr> <td>ID</td> <td>姓名</td> <td>性别</td> </tr> <volist name="data" id="vo"> <tr> <td>{$vo.id}</td> <td>{$vo.user_name}</td> <td>{$vo.sex}</td> </tr> </volist> </table> </body> </html>
PHP代码
<?php class UserAction extends Action{ public function index(){ $m=M('User'); $arr=$m->select(); $this->assign('data',$arr); $this->display(); }
ThinkPHP官网对于volist的详细介绍http://doc.thinkphp.cn/manual/volist.html