<?php
$connect = mysqli_connect("localhost", "neftenergies_app", "8wmW2AO@!ex5", "neftenergies_app");
$output = '';
$query = '';
if(isset($_POST["query"]))
{
	$search = mysqli_real_escape_string($connect, $_POST["query"]);
	$query = "
	SELECT * FROM certifications 
	WHERE neft_certificate_number = '".$search."'
	";
}
else{
    $query = "
	SELECT * FROM certifications 
	WHERE neft_certificate_number='Neft'
	";
}
$result = mysqli_query($connect, $query);
if(mysqli_num_rows($result) > 0)
{
    $output .= '<div class="alert alert-success fade in alert-dismissible">
    <a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
    <strong>Success!</strong> Certificate verified.
  </div>';

	$output .= '<div class="table-responsive">
					<table class="table table bordered">
						<tr>
							<th>Certificate</th>
							<th>Name</th>
							<th>Course Name</th>
							<th>Expiry Date</th>
						
						</tr>';
	while($row = mysqli_fetch_array($result))
	{
		$output .= '
			<tr>
				<td>'.$row["neft_certificate_number"].'</td>
				<td>'.$row["name"].'</td>
				<td>'.$row["course_name"].'</td>
				<td class="expiry-date">' . $row["expiration_date"] . '</td>
			
			</tr>
		';
	}
	echo $output;
}
else
{
	echo '<div class="alert alert-danger fade in alert-dismissible">
    <a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
    <strong>Aborted!</strong> Record Not Found.
  </div>';
}
?>