<?php
require('../config/connection.php');
$output = '';
if (isset($_POST["query"])) {
	$search = mysqli_escape_string($con, $_POST["query"]);
	$email = mysqli_escape_string($con, $_POST["email"]);
	$query = "select * from profile_mst where email = '".$_POST["email"]."' and Lower(pilgrim_name) LIKE Lower('%" . $search . "%')";
} else {
	$query = "select * from profile_mst where email = '".$_POST["email"]."' ORDER BY pilgrim_name";
}
$result = mysqli_query($con, $query);
if (mysqli_num_rows($result) > 0) {
	$output .= '
	<div class="table-responsive" style="width: 95%; height: 380px;">
		<table id="tblexportData" class="table table bordered" >
			<tr>
				<th width="50px" style=" text-align: center">Edit</th>
				<th width="50px" style=" text-align: center">Delete</th>
				<th style = "width:400px; text-align: left">pilgrim_name</th>
				<th style = "width:100px; text-align: left">age</th>
				<th style = "width:80px; text-align: left">gender</th>
				<th style = "width:200px; text-align: left">email</th>
				<th style = "width:200px; text-align: left">mobile_number</th>
				<th style = "width:200px; text-align: left">aadhaar_number</th>
				<th style = "width:300px; text-align: left">place</th>
			</tr>';
	while ($row = mysqli_fetch_array($result)) {
		$output .= '
			<tr>
				<td style="text-align: center"><button type="button" style="width:60px; height:25px;" name="update" id="' . $row["id"] . '" class="update btn btn-success btn-xs">Edit</button></td>  
				<td style="text-align: center"><button type="button" style="width:60px; height:25px;" name="delete" id="' . $row["id"] . '" class="delete btn btn-danger btn-xs">Delete</button></td>
				<td style="text-align: left">' . $row["pilgrim_name"] . '</td>
				<td style="text-align: left">' . $row["age"] . '</td>
				<td style="text-align: left">' . $row["gender"] . '</td>
				<td style="text-align: left">' . $row["email"] . '</td>
				<td style="text-align: left">' . $row["mobile_number"] . '</td>
				<td style="text-align: left">' . $row["aadhaar_number"] . '</td>
				<td style="text-align: left">' . $row["place"] . '</td>
			</tr>
		';
	}
	echo $output;
} else {
	echo 'Data Not Found';
}