
<?php
require'header.php';
require'includes/head2.php';
        
if((isset($_POST['p_name']))&&($_POST['p_name']!=""))
{
	$name=$_POST['p_name'];
	$p="select * from `patient` where `p_name`='$name' order by `p_id`";
}
else
{
$p="select * from `patient` order by `p_id`";
}
$r=$conn->query($p);
?>
<table border=4 width='1100px' style='font-size:16pt' >
		<tr>
			<th>Name</th>
			<th>Mobile</th>
			<th>Birth</th>
			<th>Place</th>
			<th colspan=2><a href='patient_new.php'><img align='center' src='../images/13.png'width=40px height=30px></a></th>
		</tr>
	
<form action="" method="POST" enctype="multipart/form-data">
		<tr>
		<td style='text-align:center'>
		
			<input  type="text" name="p_name" placeholder="Search By Name" id="tag" >
			
		</td >
		<td style="text-align:center">
		<input class="button-6" type="submit" name="search" value="Search">
		</td>
		<td colspan=4>
</td>	
		</tr>
	</form>
	<?php
while($row=mysqli_fetch_array($r))
{
	echo"<tr>
			<td>".$row['p_name']."</td>
			<td>".$row['p_mobile']."</td>
			<td style='text-align:center'>";
			$dateOfBirth = $row['p_age'];
			$today = date("Y-m-d");
			$diff = date_diff(date_create($dateOfBirth), date_create($today));
			echo $diff->format('%y')." Years";
			echo"</td><td>".$row['place']."</td>
			<td style='text-align:center'><a href='patient_del.php?p_id=".$row['p_id']."'><img align='center' src='../images/9.png'width=40px height=''></a></td>
			<td style='text-align:center'><a href='patient_edit.php?p_id=".$row['p_id']."'><img align='center' src='../images/edit.png'width=30px height=''></a></td>
		</tr>";
}
echo"</table>";
require 'includes/foot.php';?>


