S132 Filter query and result

S132 Filter query and result
<!DOCTYPE html>
<html>
<body>

<?php
$servername = "localhost";
$username = "saurabh";
$password = "123456";
$dbname = "saurabh";

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}


$mobile=$_GET["mobile"];
$country=$_GET["country"];
$city=$_GET["city"];

if($city=="select" && $country=="select"){
    $sql = "SELECT * FROM regform";
}
else if($city=="select" || $country=="select"){
if($country=="select"){
    $sql = "SELECT * FROM regform WHERE city='$city'";
}
if($city=="select"){
    $sql = "SELECT * FROM regform WHERE country='$country'";
}
}
else{
    $sql = "SELECT * FROM regform WHERE country = '$country' and city='$city'";
    }
    $result = $conn->query($sql);
    if ($result->num_rows > 0) {
    // output data of each row
    while($row = $result->fetch_assoc()) {
        echo "<br> username: ". $row["username"]." - Mobile: ". $row["mobile"].
        "country: ".$row["country"]." - city: ". $row["city"]."<br>"
        ;
    }

} else {
    echo "0 results";
}

$conn->close();
?>

</body>
</html>

Take Your Free Live Demo Class Now

We Will Call Back You Shortly

Enter Your DETAILS BELOW

We Will Send You the Course Fees Details In Below Number

Enter Your DETAILS BELOW

We Will Call Back You Shortly

Enter Your DETAILS BELOW

We Will Call Back You Shortly

Enter Your DETAILS BELOW

Enter Your DETAILS BELOW TO take

free demo class