扫码关注官方订阅号
84669人学习
65727人学习
82984人学习
467778人学习
498837人学习
471966人学习
256484人学习
152542人学习
224170人学习
139536人学习
81804人学习
85022人学习
11944人学习
20001人学习
60816人学习
5487人学习
15007人学习
2150人学习
6980人学习
194925人学习
359900人学习
1142人学习
19058人学习
3206人学习
180550人学习
48569人学习
17603人学习
40936人学习
1049人学习
750人学习
32909人学习
按照这样的查询条件,搜索出数据库中的用户名和密码怎么写?
直接where后面加 多个and 条件,如果值没选,就为空
不能上传图片。。。
好
最后一个自己加
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没多久 我用的 字符串拼接做的 有没有别的更好地办法我不太清楚
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
扫描下载App
Copyright 2014-2024 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
精品班
技术支持
技术咨询
学习群
会员优惠
返回顶部
直接where后面加 多个and 条件,如果值没选,就为空
不能上传图片。。。
好
最后一个自己加
最后一个自己加
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没多久 我用的 字符串拼接做的 有没有别的更好地办法我不太清楚