把他的sql查詢的寫死的變量, 你用搜索穿過的替換掉就可以了啊,
sql的 where根據篩選條件改變而改變,舉個例子:
$filter['brand'] = isset($_REQUEST['brand']) ? trim($_REQUEST['brand']) : '';//品牌 $filter['price'] = isset($_REQUEST['price']) ? trim($_REQUEST['price']) : '';//价格 $filter['attribute'] = isset($_REQUEST['attribute']) ? trim($_REQUEST['attribute']) : '';//属性 $where = " WHERE 1"; if($filter['brand'] != ''){ $where .= " AND brand=" . addslashes($filter['brand']); } if($filter['price'] != ''){ $where .= " AND price=" . addslashes($filter['price']); } if($filter['attribute'] != ''){ $where .= " AND attribute=" . addslashes($filter['attribute']); }