不去做怎么知道做不到,用心做好每一天做好每一件|

轻风细雨_林木木

园龄:6年3个月粉丝:4关注:1

Think PHP 学习笔记 10.查询方式实例演示

一. 制作表格内容搜索
1.在模板的table上加form表单

<form action = '__URL__/search' method = 'post'>
用户名:<input type="text" name="username">
性别:
男<input type="radio" name="sex" value="1">
女<input type="radio" name="sex" value="0">
</from>
  1. 在模块search里, 写搜索的方法
public function search(){
if(isset($_POST['username'])){
$where['username']=array('like',"%$_POST['username']%");
}
if(iseet($_POST['sex'])){
$where[
'sex']=array('like',"%$_POST['sex']%")
}
//实例化数据库
$m = M('User');
$arr = $m->where($where)->select();
$this->arr = $arr;
$this->display('index');
}

本文作者:轻风细雨_林木木

本文链接:https://www.cnblogs.com/linzhifen5/p/16961530.html

版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。

posted @   轻风细雨_林木木  阅读(13)  评论(0编辑  收藏  举报
点击右上角即可分享
微信分享提示
评论
收藏
关注
推荐
深色
回顶
收起
  1. 1 尚好的青春 孙燕姿
  2. 2 孙燕姿
  3. 3 克卜勒 孙燕姿
- 孙燕姿
00:00 / 00:00
An audio error has occurred, player will skip forward in 2 seconds.