$sql_dss = " select *
from house h, facility f, public p
where h.HouseID = p.HouseID
and h.HouseID = f.HouseID ";
switch($_REQUEST['Price'])
case 0 : $sql_dss.= " and h.Price is Null "; break;
case 1 : $sql_dss.= " and h.Price < 2000000 "; break;
case 2 : $sql_dss.= " and h.Price between 2000000 and 5000000 "; break;
case 5 : $sql_dss.= " and h.Price >5000000 "; break;
$result_dss = mysql_query($sql_dss) or die ( mysql_error()) ;
$arr_dss = mysql_fetch_array($result_dss);
print_r ($arr_dss);
ผมอิงมาจากพี่ mr.win Code (PHP)
<?
$strSQL = "SELECT * FROM table WHERE 1 ";
if($_POST["txt1"] != "")
{
$strSQL .= " AND F1 = '".$_POST["txt1"]."' ";
}
if($_POST["txt2"] != "")
{
$strSQL .= " AND F2 = '".$_POST["txt2"]."' ";
}
?>