How to implement multi-condition query database in php: 1. Make a form and create a table to display the table; 2. Call the encapsulation class, create the corresponding conditions, and check whether the data is empty; 3. Just use php code to traverse and query the tables of the database.
The operating environment of this article: Windows 7 system, PHP version 7.1, Dell G3 computer
How to query the database with multiple conditions in php?
Multi-condition query:
1. First make a form and create a table to display the table:
代号 | 名称 | 系列 | 上市时间 | 价格 |
2. Call the encapsulation class, create corresponding conditions, and check whether the data is empty:
3. Use PHP code to traverse the database table and add the keywords Turns red (php should be embedded in table):
query($sql);foreach($arr as $v) { $str = str_replace($name,"{$name}",$v[1]); echo "";}?> {$v[0]} {$str} {$v[2]} {$v[3]} {$v[7]}
The final result is:
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of How to query the database with multiple conditions in php. For more information, please follow other related articles on the PHP Chinese website!