I tried this:
$result = mysql_query("SELECT * from business WHERE ptype = '".$_GET["ptype"]."' AND state = '".$_GET["state"]."' AND city = '".$_GET["city"]."'") or die(mysql_error());
but if I don’t put 3 GET’s I get an error from MySql:
localhost/get_allinfo.php?ptype=PUB&state=Center
Then I get a MySQL error
I tried this:
but it doesn’t matter if I put “state” in URL $_GET["ptype"]) & (isset($_GET["state"]))
I get the result from “ptype” only
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());
}
This should make it a bit more robust: