User模块的方法; public function search(){ var_dump($_POST); } <!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="Generator" content="EditPlus?"> <meta name="Author" content=""> <meta name="Keywords" content=""> <meta name="Description" content=""> <title>Document</title> <script> function jump(){ window.location="http://localhost:8080/thinkphp/index.php/User/add"; } </script> </head> <body> <form action='/thinkphp/index.php/User/search' method='post'> 用户名:<input type='text' name='username'/> 性别:<input type='radio' name='sex' value='1'/>男<input type='radio' name='sex' value='0'/>女 <input type='submit' value='搜素'/> </form> <h1>scan show 你好 hhhello world</h1> <table border='1' width='500' align='center'> <tr> <th>id</th> <th>username</th> <th>sex</th> <th>操作</th> </tr> <volist name='data' id='vo'> <tr> <td><{$vo.id}></td> <td><{$vo.username}></td> <td><{$vo.sex}></td> <td><a href="http://localhost:8080/thinkphp/index.php/User/del/id/<{$vo.id}>">删除</a>|<a href="http://localhost:8080/thinkphp/index.php/User/modify/id/<{$vo.id}>">修改</a></td> </tr> </volist> </table> <center> <button onclick="jump()">添加用户</button> </center> </body> </html> <form action='/thinkphp/index.php/User/search' method='post'> form表单的动作是 调用/thinkphp/index.php/User/search public function search(){ var_dump($_POST); } 打印出的内容: array (size=2) 'username' => string 'xxyy' (length=4) 'sex' => string '1' (length=1) public function search(){ var_dump($_POST); // 获取POSTT的数据,根据数据组查询的条件,根据条件从数据库中获取数, //返回给页面遍历 把数据分配给前台模板,去找index的前台模板 $m=M('user'); if $where['username']=$_POST['username'] $where['sex']=$_POST['sex'] $arr=$m->where($where)->select() $this->assign('data',$arr); $this->display('index'); } 组装的SQL: SELECT * FROM `user` WHERE ( `username` = 'xxyy' ) AND ( `sex` = '0' ) [ RunTime:0.015743s ] $m=M('user'); if (isset($_POST['username'])){ $where['username']=$_POST['username']; }; if (isset($_POST['sex'])){ $where['sex']=$_POST['sex']; }; #$where['logic'] echo $where['username']; echo $where['sex']; $arr=$m->where($where)->select(); $this->assign('data',$arr); $this->display('index'); } $m=M('user'); if (isset($_POST['username']) && $_POST['username'] !=null ){ $where['username']=$_POST['username']; }; if (isset($_POST['sex']) && $_POST['sex'] !=null){ $where['sex']=$_POST['sex']; }; #$where['logic'] echo $where['username']; echo $where['sex']; $arr=$m->where($where)->select(); $this->assign('data',$arr); $this->display('index'); } 等价于; <form action='/thinkphp/index.php/User/search' method='post'> <form action='__URL__/search' method='post'>
查询方式实例演示
转载本文章为转载内容,我们尊重原作者对文章享有的著作权。如有内容错误或侵权问题,欢迎原作者联系我们进行内容更正或删除文章。
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
实例演示如何使用CCE XGPU虚拟化
CCE GPU虚拟化采用自主研发的xGPU虚拟化技术,能够动态对GPU设备显存与算力进行划分,单个GPU卡最多虚拟化成20个GPU虚拟设备。
虚拟化 Deployment Pod CCE 资源利用率 -
MySQL优化查询的几种方式
MySQL优化查询的几种方式
索引 limit join -
Java反射 - [实例演示] 创建类的对象多种方式
Java通过反射可以创建类的对象创建类的对象方式除了new,Class.newInstance()这两种方
Java反射 创建私有构造器对象 ico 构造器 创建对象 -
nginx负载均衡实例演示
1、准备三台虚拟机2、nginx 安装3、web服务器的配置4、修改配置文件4.1 配置方式一4.2配置方式二5、验
nginx负载均衡实例演示 nginx web服务器 负载均衡