<? require_once "application_top.php"; ?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Search Blood Donors || Bihar Blood Bank</title>



<? include ("include/header.php"); ?>
	<table id="containerTable">
	<tr>
		<td width="220">
		<? require "left.php";?>
		</td>
		
		<td width="500px;">
		<br/>
		<?=$msg;?>
		<br/>
	<table width="100%" border="1" cellspacing="0" cellpadding="4">
  <tr>
   
    <td width="25%" bgcolor="#CCCCCC"><strong>Name</strong></td>
	    <td width="5%" bgcolor="#CCCCCC"><strong>Bloodgroup</strong></td>
	    <td width="20%" bgcolor="#CCCCCC"><strong>Email</strong></td>
    <td width="5%" bgcolor="#CCCCCC"><strong>State</strong></td>
    <td width="10%" bgcolor="#CCCCCC"><strong>City</strong></td>
	<td width="10%" bgcolor="#CCCCCC"><strong>Mobile</strong></td>
  </tr>
<?php


if ($_REQUEST["bloodgroup"]<>'') {
	$search_city = " AND bloodgroup='".mysql_real_escape_string($_REQUEST["bloodgroup"])."' AND LIKE = '1'";	
}


if ($_REQUEST["state"]<>'') {
	$search_city = " AND state='".mysql_real_escape_string($_REQUEST["state"])."'AND LIKE = '1'";	
}



if ($_REQUEST["city"]<>'') {
	$search_city = "AND city='".mysql_real_escape_string($_REQUEST["city"])."'AND LIKE = '1'";	
}


if ($_REQUEST["bloodgroup"]<>'' and $_REQUEST["state"]<>'' and $_REQUEST["city"]<>'') {
	$sql = "SELECT * FROM ".$SETTINGS["data_table"]." WHERE bloodgroup = '".mysql_real_escape_string($_REQUEST["bloodgroup"])."' AND state = '".mysql_real_escape_string($_REQUEST["state"])."'AND city = '".mysql_real_escape_string($_REQUEST["city"])."'AND LIKE = '1'";	

}


else if ($_REQUEST["bloodgroup"]<>'' and $_REQUEST["state"]<>'') {
	$sql = "SELECT * FROM ".$SETTINGS["data_table"]." WHERE bloodgroup = '".mysql_real_escape_string($_REQUEST["bloodgroup"])."' AND state = '".mysql_real_escape_string($_REQUEST["state"])."'AND LIKE = '1'";	

}

else if ($_REQUEST["bloodgroup"]<>'' and $_REQUEST["city"]<>'') {
	$sql = "SELECT * FROM ".$SETTINGS["data_table"]." WHERE bloodgroup = '".mysql_real_escape_string($_REQUEST["bloodgroup"])."' AND city = '".mysql_real_escape_string($_REQUEST["city"])."'AND LIKE = '1'";	
} else if ($_REQUEST["bloodgroup"]<>'') {
	$sql = "SELECT * FROM ".$SETTINGS["data_table"]." WHERE bloodgroup = '".mysql_real_escape_string($_REQUEST["bloodgroup"])."'AND LIKE = '1'";	
} else if ($_REQUEST["state"]<>'') {
	$sql = "SELECT * FROM ".$SETTINGS["data_table"]." WHERE state = '".mysql_real_escape_string($_REQUEST["state"])."'".$search_city;
}else if ($_REQUEST["city"]<>'') {
	$sql = "SELECT * FROM ".$SETTINGS["data_table"]." WHERE city = '".mysql_real_escape_string($_REQUEST["city"])."'".$search_city;
}
 else {
	$sql = "SELECT * FROM ".$SETTINGS["data_table"]." LIMIT 0,10".$search_city;
}

$sql_result = mysql_query ($sql, $connection ) or die ('request "Could not execute SQL query" '.$sql);
if (mysql_num_rows($sql_result)>0) {
	while ($row = mysql_fetch_assoc($sql_result)) {
?>
  <tr>
 
    <td width="25%"><?php echo $row["fname"]; ?></td>
      <td width="5%" ><?php echo $row["bloodgroup"]; ?></td>
      <td width="20%"><?php echo $row["email"]; ?></td>
	   <td width="5%"><?php echo $row["state"]; ?></td>
       <td width="10%"><?php echo $row["city"]; ?></td>
	   <td width="10%"><?php echo $row["mobile"]; ?></td>
  </tr>
<?php
	}
} else {
?>
<tr><td colspan="5">No results found.</td>
<?php	
}
?>
	</tr>
	</table>
<td width="220" align="right">
		<? require "right.php";?>
		</td>
	</table>
	
<? include ("include/footer.php"); ?>
