1.多条件做的时候有些蒙 不过理清楚了挺简单的
if ($name) {
$wherelist[] = "name like '%" .$name. "%'";
// (id like '%" .$id. "%') or (name like '%" .$name. "%') or (subject like '%" .$subject. "%')
}
if ($mobile) {
$wherelist[] = "mobile like '%" .$mobile. "%'";
//$where['mobile'] = $mobile;
}
if ($car_code) {
$wherelist[] = "car_code like '%" .$car_code. "%'";
//$where['car_code'] = $car_code;
}
if ($is_car) {
$whereand[] = " is_car={$is_car} ";
}
if ($status) {
$whereand[] = " status={$status} ";
}
//组装查询条件
if(count($wherelist) > 0){
$where = implode(' or ' , $wherelist);
}
//组装查询条件
if(count($whereand) > 0 && $where){
$aa = implode(' and ' , $whereand);
$where = $where.' and '.$aa;
}elseif(count($whereand) > 0 && !$where){
$where = implode(' and ' , $whereand);
}
//判断查询条件
$where = isset($where) ? $where : '';
网友评论