php method to implement multi-condition fuzzy query: first receive the post value; then pass "if(!empty($name)){$where['name'] = array('like','% '.$name.'%')..." method encapsulates the fuzzy query and assigns it to an array.
The operating environment of this article: Windows 7 system, PHP version 7.1, Dell G3 computer.
PHP Fuzzy Query (Multiple Conditions)
The code is as follows:
//<!--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();
Recommended learning: "PHP Video Tutorial》
The above is the detailed content of How to implement multi-condition fuzzy query in PHP. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

WebStorm Mac version
Useful JavaScript development tools

SublimeText3 English version
Recommended: Win version, supports code prompts!

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

Atom editor mac version download
The most popular open source editor
