本文操作环境:windows7系统、php7.1版、dell g3电脑。
php模糊查询(多条件)
代码如下:
//<!--php模糊查询 --> //接收post传值$name = i('post.name'); $mail = i('post.mail'); $age = i('post.age'); if(!empty($name)){ //封装模糊查询 赋值到数组 $where['name'] = array('like','%'.$name.'%'); } if(!empty($mail)){ $where['mail'] = array('like','%'.$mail.'%'); } if(!empty($age)){ $where['age'] = $age; } //如果查询条件是or的关系请打开,一般都是and关系。 $where['_logic']='or'; $test = m('table')->where($where)->select();
推荐学习:《php视频教程》
以上就是php多条件模糊查询怎么实现的详细内容。