我试过这个:
$result = mysql_query("SELECT * from business WHERE ptype = '".$_GET["ptype"]."' AND state = '".$_GET["state"]."' AND city = '".$_GET["city"]."'") or die(mysql_error());
但如果我不放 3 个 GET,我会从 MySql 收到一个错误:
localhost/get_allinfo.php?ptype=PUB&state=Center
然后我得到一个 MySQL 错误
我试过这个:
但是如果我把“状态”放在 URL 中并不重要$_GET["ptype"]) & (isset($_GET["state"]))
我只从“ptype”得到结果
if (isset($_GET["ptype"])) {
$ptype = $_GET["ptype"];
$result = mysql_query("SELECT * from business WHERE ptype = '$ptype'") or die(mysql_error());
}elseif(isset($_GET["ptype"]) & (isset($_GET["state"]))){
$ptype = $_GET["ptype"];
$state = $_GET["state"];
$result = mysql_query("SELECT * from business WHERE ptype = '$ptype' and WHERE state = '$state") or die(mysql_error());
}else {
$result = mysql_query("SELECT * FROM `business`") or die(mysql_error());
}