把他的sql查询的写死的变量, 你用搜索穿过的替换掉就可以了啊,
sql的 where根据筛选条件改变而改变,举个例子:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | $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']);
}
|
Copier après la connexion