According to such query conditions, how to search for the user name and password in the database?
Directly add multiple and conditions after where. If the value is not selected, it will be empty.
Cannot upload pictures. . .
good
Add the last one yourself
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 ";
case 3:
$sql = $sql."and cost_price>=200 and cost_price<=299 ";
case 4:
$sql = $sql."and cost_price>=300 ";
case 5:
$sql = $sql."and cost_price =0 ";
}
if($shoujia!=0){
switch ($shoujia) {
$sql = $sql."and sellprice>=0 and sellprice<=99 ";
$sql = $sql."and sellprice>=100 and sellprice<200 ";
$sql = $sql."and sellprice>=200 and sellprice<=299 ";
$sql = $sql."and sellprice>=300 ";
我也是刚学php没多久 我用的 字符串拼接做的 有没有别的更好地办法我不太清楚
Directly add multiple and conditions after where. If the value is not selected, it will be empty.
Cannot upload pictures. . .
good
Add the last one yourself
Add the last one yourself
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没多久 我用的 字符串拼接做的 有没有别的更好地办法我不太清楚