I am trying to search particular data using multiple criteria. I am using age,location, type as multiple search criteria. If the age is 6-12 and type is outdoor only the particular criteria as to be displayed . In the below code it searches if age group is 6-12 and location is oudoor it displays value of age 6-12 and 12-18 whose location is outdoor.It as to be search even if only 1 criteria i.e age or location or type is entered.
Here is the code
<?php
$username = "root";
$password = "";
$hostname = "localhost";
$db = "game";
// Connect to server and select database.
$conn=mysql_connect($hostname,$username,$password)or die("cannot connect");
mysql_select_db($db,$conn)or die("cannot select DB");
if(!$conn)
{
die("cannot connect");
}
if(isset($_POST['submit']))
{
$name=$_POST["name"];
$age=$_POST["age"];
$location=$_POST["location"];
$type=$_POST["type"];
$query = "SELECT * FROM `game1` WHERE age ='$age' or location='$location' or type='$type'";
$run = mysql_query($query);
if(mysql_num_rows($run)>0){
header("Location: gamesearch1.php?age=$age&location=$location&type=$type");
}
else {
echo "<script>alert('No members Yet!')</script>";
}
}
?>