ThinkPHP学习笔记(三)之查询数据库给网页赋值

本人学习的Thinkphp版本为3.1.2,为比较早的版本,是在网易云课堂上跟着赵桐正老师学习的,视频地址http://study.163.com/course/courseMain.htm?courseId=266024
本文是个人学习笔记,属于原创,转载请注明出处。

IndexController.class.php//Index页面的控制器文件

Public function show()
{
    $m=M('message');
    $info=$m->select();
    //dump($info);
    $this->assign("info",$info);
    $this->display();
}

Show.html

<!DOCTYPEhtml>
<htmllang="en">
<head>
<metacharset="UTF-8">
<title>ShowAllMessage</title>
</head>
<body>
    <volistname="info"id="i">
        {$i.title}<br>
        {$i.content}<br>
        {$i.time|date="Y-m-dH:i:s",###}<br>
        <ahref="{:U('Index/edit',array('id'=>$i['id']))}">Edit</a>
        <ahref="{:U('Index/delete',array('id'=>$i['id']))}">Delete</a>
        <hr>
    </volist>
</body>
</html>

表单传值

method='post'
$data["name] = $_POST["namer"];
或者
$data["name] = I("name");

猜你喜欢

转载自blog.csdn.net/qq_38137411/article/details/81287579
今日推荐