多条件动态筛选,该如何处理
多条件动态筛选
价格:1000 2000 3000
时间:2001 2002 2003
清除价格 清除时间 全部清除
现在点1000 已经有内容出来,不过MYSQL语句错误,再点一下2001,符合两个条件的内容也出来了,SQL没有提示错误。
$result=mysql_query('select * from news_c where title='.$title.' or f_id='.$f_id.'' );
现在要怎么样改sql才不会因为只点了一个条件而出错。
------解决方案--------------------
根据传入参数的数量,动态组装 sql 串
------解决方案--------------------
给你一个测试例
- PHP code
$jg = array(1000, 2000, 3000);$sj = array(2001, 2002, 2003);if(isset($_GET['act'])) { $k = substr($_GET['act'], 3); unset($_GET['act']); if($k == 'all') $_GET = array(); else unset($_GET[$k]);} echo '<br>价格:';$param = getparam('jg');foreach($jg as $v) echo " <a href="?%24param%24v">$v</a>";echo '<br>时间:';$param = getparam('sj');foreach($sj as $v) echo " <a href="?%24param%24v">$v</a>";$param = http_build_query($_GET);echo "<p><a href="?act=deljg&%24param">清除价格</a> <a href="?act=delsj&%24param">清除时间</a> <a href="?act=delall&%24param">全部清除</a>";echo "</p><p>select * from tbl_name " . expr();function getparam($k) { $param = $_GET; if(isset($_GET[$k])) unset($param[$k]); $param[$k] = ''; return http_build_query($param);}function expr($expr='and') { if(! $_GET) return ''; foreach($_GET as $k=>$v) $r[] = "$k='$v'"; return 'where ' . join(" $expr ", $r);}</p><div class="clear"> </div>

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

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











Many users will choose the Huawei brand when choosing smart watches. Among them, Huawei GT3pro and GT4 are very popular choices. Many users are curious about the difference between Huawei GT3pro and GT4. Let’s introduce the two to you. . What are the differences between Huawei GT3pro and GT4? 1. Appearance GT4: 46mm and 41mm, the material is glass mirror + stainless steel body + high-resolution fiber back shell. GT3pro: 46.6mm and 42.9mm, the material is sapphire glass + titanium body/ceramic body + ceramic back shell 2. Healthy GT4: Using the latest Huawei Truseen5.5+ algorithm, the results will be more accurate. GT3pro: Added ECG electrocardiogram and blood vessel and safety

If you are an IT administrator or technology expert, you must be aware of the importance of automation. Especially for Windows users, Microsoft PowerShell is one of the best automation tools. Microsoft offers a variety of tools for your automation needs, without the need to install third-party applications. This guide will detail how to leverage PowerShell to automate tasks. What is a PowerShell script? If you have experience using PowerShell, you may have used commands to configure your operating system. A script is a collection of these commands in a .ps1 file. .ps1 files contain scripts executed by PowerShell, such as basic Get-Help

Why Snipping Tool Not Working on Windows 11 Understanding the root cause of the problem can help find the right solution. Here are the top reasons why the Snipping Tool might not be working properly: Focus Assistant is On: This prevents the Snipping Tool from opening. Corrupted application: If the snipping tool crashes on launch, it might be corrupted. Outdated graphics drivers: Incompatible drivers may interfere with the snipping tool. Interference from other applications: Other running applications may conflict with the Snipping Tool. Certificate has expired: An error during the upgrade process may cause this issu simple solution. These are suitable for most users and do not require any special technical knowledge. 1. Update Windows and Microsoft Store apps

1. Java calls post interface 1. Use URLConnection or HttpURLConnection that comes with java. There is no need to download other jar packages. Call URLConnection. If the interface response code is modified by the server, the return message cannot be received. It can only be received when the response code is correct. to return publicstaticStringsendPost(Stringurl,Stringparam){OutputStreamWriterout=null;BufferedReaderin=null;StringBuilderresult=newSt

Part 1: Initial Troubleshooting Steps Checking Apple’s System Status: Before delving into complex solutions, let’s start with the basics. The problem may not lie with your device; Apple's servers may be down. Visit Apple's System Status page to see if the AppStore is working properly. If there's a problem, all you can do is wait for Apple to fix it. Check your internet connection: Make sure you have a stable internet connection as the "Unable to connect to AppStore" issue can sometimes be attributed to a poor connection. Try switching between Wi-Fi and mobile data or resetting network settings (General > Reset > Reset Network Settings > Settings). Update your iOS version:

php提交表单通过后,弹出的对话框怎样在当前页弹出php提交表单通过后,弹出的对话框怎样在当前页弹出而不是在空白页弹出?想实现这样的效果:而不是空白页弹出:------解决方案--------------------如果你的验证用PHP在后端,那么就用Ajax;仅供参考:HTML code

In Linux, URL or Curl client is a popular command line utility that allows you to transfer data over the network using various protocols such as HTTPS, HTTP, FTP, etc. It allows you to send and receive data using its get, post and request methods. Among them, you need to use the "get" method frequently. Therefore, it becomes crucial to learn various methods and various options that you can use to increase your productivity. "Performing a curl operation is as simple as entering a few simple commands. Although it seems simple, many users do not fully realize its potential. Therefore, this short guide provides some information on how to perform curl operations on Linux systems. Example using the "curlget" command." Curl

1. The first method of the Controller layer receiving parameters without any annotations is the simplest. I seriously doubt why it was not used before. Who knows. . But this time it really worked. The simplest way is to add the Controller interface without adding any annotations! ! ! SpringBoot handles this automatically. The code is as follows: /***@authorzhangzhixiang*@sincev1.0.0*/@RestController@RequestMapping(path="/ui/institution")publicclassInstitutionManagemen
