According to such query conditions, how to search for the user name and password in the database?
**推广网2018-10-10 11:35:52
Directly add multiple and conditions after where. If the value is not selected, it will be empty.
ll2018-08-13 17:21:16
if($chengbenjia!=0){
switch ($chengbenjia) {
case 1:
$sql = $sql."and cost_price>=0 and cost_price<=99 ";
break;
case 2:
$sql = $sql."and cost_price>=100 and cost_price<200 ";
break;
case 3:
$sql = $sql."and cost_price>=200 and cost_price<=299 ";
break;
case 4:
$sql = $sql."and cost_price>=300 ";
break;
case 5:
$sql = $sql."and cost_price =0 ";
break;
}
}
if($shoujia!=0){
switch ($shoujia) {
case 1:
$sql = $sql."and sellprice>=0 and sellprice<=99 ";
break;
case 2:
$sql = $sql."and sellprice>=100 and sellprice<200 ";
break;
case 3:
$sql = $sql."and sellprice>=200 and sellprice<=299 ";
break;
case 4:
$sql = $sql."and sellprice>=300 ";
break;
}
}
我也是刚学php没多久 我用的 字符串拼接做的 有没有别的更好地办法我不太清楚