if(!empty($style_id)){
$sql = "SELECT * FROM tbl_search WHERE style_id LIKE '%".$style_id."%' order by id asc";
}else if(!empty($price)){
$sql = "SELECT * FROM tbl_search WHERE price LIKE '%".$price."%' order by id asc";
}else if(!empty($location)){
$sql = "SELECT * FROM tbl_search WHERE location LIKE '%".$location."%' order by id asc";
}else if(!empty($style_id) && !empty($price)){
$sql = "SELECT * FROM tbl_search WHERE style_id LIKE '%".$style_id."%' AND price LIKE '%".$price."%' order by id asc";
echo"$sql";
}else if(!empty($style_id) && !empty($location)){
$sql = "SELECT * FROM tbl_search WHERE style_id LIKE '%".$style_id."%' AND location LIKE '%".$location."%' order by id asc";
}else if(!empty($price) && !empty($location)){
$sql = "SELECT * FROM tbl_search WHERE price LIKE '%".$price."%' AND location LIKE '%".$location."%' order by id asc";
}else if(!empty($style_id) && !empty($price) && !empty($location)){
$sql = "SELECT * FROM tbl_search WHERE style_id LIKE '%".$style_id."%' AND price LIKE '%".$price."%' AND location LIKE '%".$location."%'";
}else{
$sql = "SELECT * FROM tbl_search order by id asc";
}
if(!empty($style_id)){
$sql = "SELECT * FROM tbl_search WHERE style_id LIKE '%".$style_id."%' order by id asc";
}else if(!empty($price)){
$sql = "SELECT * FROM tbl_search WHERE price LIKE '%".$price."%' order by id asc";
}else if(!empty($location)){
$sql = "SELECT * FROM tbl_search WHERE location LIKE '%".$location."%' order by id asc";
แต่ตรงนี้ เมื่อเอา 2 เงื่อนไขมา and กันมันใช้ไม่ได้ค่ะ
}else if(!empty($style_id) && !empty($price)){
$sql = "SELECT * FROM tbl_search WHERE style_id LIKE '%".$style_id."%' AND price LIKE '%".$price."%' order by id asc";
echo"$sql";
}else if(!empty($style_id) && !empty($location)){
$sql = "SELECT * FROM tbl_search WHERE style_id LIKE '%".$style_id."%' AND location LIKE '%".$location."%' order by id asc";
}else if(!empty($price) && !empty($location)){
$sql = "SELECT * FROM tbl_search WHERE price LIKE '%".$price."%' AND location LIKE '%".$location."%' order by id asc";
}else if(!empty($style_id) && !empty($price) && !empty($location)){
$sql = "SELECT * FROM tbl_search WHERE style_id LIKE '%".$style_id."%' AND price LIKE '%".$price."%' AND location LIKE '%".$location."%'";
}else{
$sql = "SELECT * FROM tbl_search order by id asc";
}
if(!empty($style_id)){
$sql = "SELECT * FROM tbl_search WHERE style_id LIKE '%".$style_id."%' order by id asc";
}else if(!empty($style_id) && !empty($location)){
$sql = "SELECT * FROM tbl_search WHERE style_id LIKE '%".$style_id."%' AND location LIKE '%".$location."%' order by id asc";
}