<?php
require_once('upper.php');
if(isset($_COOKIE['AdminCookie'])){
if(isset($_POST['submit'])){
require_once('database.php');
$ActivityName =$_POST['ActivityName'];
$EventName =$_POST['EventName'];
$BloodGroup =$_POST['BloodGroup'];
$Location =$_POST['Location'];
$Age =$_POST['Age'];
//$Sex =$_POST['Sex'];
echo $ActivityName;
$query="select * from registration WHERE Flag='A' AND BloodGroup= '$BloodGroup' AND Age ='$Age'";
//$query="select * from registration WHERE Flag='A' AND Address like '%$Location%'";
$result=mysqli_query($dbc,$query) or die('Not Connected');
while($row=mysqli_fetch_array($result))
{
echo $row['Name'];
}
/*if(isset($_POST['ActivityName']))
{
require_once('database.php');
$Search=$_POST['Search'];
$query="select * from registration where Flag='A' AND Activity like '%,$Search,%'";
$result=mysqli_query($dbc,$query) or die('Not Connected');
while($row=mysqli_fetch_array($result))
{
echo "<table border='2'><tr><td> Name--".$row['Name']."</td>
<td>Contact Number--".$row['ContactNumber']."</td>
<td>Email--".$row['Email']."</td>
<td>Address--".$row['Address']."</td></tr></table>";
}
}
elseif(isset($_POST['EventId'])){
require_once('database.php');
$Search=$_POST['Search'];
$query="SELECT * FROM registration r JOIN participation p ON r.LoginId = p.LoginId WHERE r.Flag='A' AND p.EventId ='$Search'";
$result=mysqli_query($dbc,$query) or die('Not Connected');
while($row=mysqli_fetch_array($result)){
echo "<table border='2'><tr><td> Name--".$row['Name']."</td>
<td>Contact Number--".$row['ContactNumber']."</td>
<td>Email--".$row['Email']."</td>
<td>Address--".$row['Address']."</td></tr></table>";
}}
elseif(isset($_POST['Location']))
{
require_once('database.php');
$Search=$_POST['Search'];
$query="select * from registration where Flag='A' AND Address like '%$Search%'";
$result=mysqli_query($dbc,$query) or die('Not Connected');
while($row=mysqli_fetch_array($result))
{
echo "<table border='2'><tr><td> Name--".$row['Name']."</td>
<td>Contact Number--".$row['ContactNumber']."</td>
<td>Email--".$row['Email']."</td>
<td>Address--".$row['Address']."</td></tr></table>";
}
}
elseif(isset($_POST['BloodGroup']))
{
require_once('database.php');
$Search=$_POST['Search'];
$query="select * from registration where Flag='A' AND BloodGroup ='$Search'";
$result=mysqli_query($dbc,$query) or die('Not Connected');
while($row=mysqli_fetch_array($result))
{
echo "<table border='2'><tr><td> Name--".$row['Name']."</td>
<td>Contact Number--".$row['ContactNumber']."</td>
<td>Email--".$row['Email']."</td>
<td>Address--".$row['Address']."</td></tr></table>";
}*/
}
?>
<html><body><form action='<?php echo $_SERVER['PHP_SELF']?>' method="post">
<?php
require_once('database.php');
$result=mysqli_query($dbc,"select * from Activity");
echo "Select Activity   
<select name='ActivityName'>
<option></option>";
while($row=mysqli_fetch_array($result)){
echo "
<option>".$row['Title']."</option>";
}
echo "</select><br>";
$result=mysqli_query($dbc,"select * from events");
echo "Select Events   
<select name='EventName'>
<option></option>";
while($row=mysqli_fetch_array($result)){
echo "
<option>".$row[Title]."</option>";
}
echo "</select><br>";
$result=mysqli_query($dbc,"select * from registration");
echo "Select Blood Group   
<select name='BloodGroup'>
<option></option>";
while($row=mysqli_fetch_array($result)){
echo "
<option>".$row[BloodGroup]."</option>";
}
echo "</select><br>";
echo" Enter Location   
<input type='text' name='Location'><br>";
echo"Enter Age   
<input type='text' name='Age'><br>";
echo "Enter Sex   
<select>
<option></option>
<option>Male</option>
<option>Female</option>
</select><br>";
echo "<input type='submit' name='submit' value='Search'><br>";
echo"</form></body></html>";
echo "<a href='log_out.php'>Admin Log out</a><br>";
echo "<a href='AdminHome.php'>Back to Admin Home</a>";
}
else{echo 'Restricted Page'."<br><br>".'Access Denied';}
require_once('lower.php');?>
Hi frds..........
I want to search by "Age" and "Blood Group" first.On combobox when I select both Age and Blood Group it gives the rihgt result but when I select only one field and other remain blank it not works.............
I want when I select only one field, query executes for one condition only....
It means when I select only Blood Group and leave Age field blank it displays all Name have required Blood Group without any age condition.