<?php include("inc/db.php");?>
<!DOCTYPE html>
<html lang="en">

<head>

	<!-- META ============================================= -->
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="keywords" content="" />
	<meta name="author" content="" />
	<meta name="robots" content="" />
	
	<!-- DESCRIPTION -->
	<meta name="description" content="EduChamp : Education HTML Template" />
	
	<!-- OG -->
	<meta property="og:title" content="EduChamp : Education HTML Template" />
	<meta property="og:description" content="EduChamp : Education HTML Template" />
	<meta property="og:image" content="" />
	<meta name="format-detection" content="telephone=no">
	
	<!-- FAVICONS ICON ============================================= -->
	<link rel="icon" href="assets/images/favicon.ico" type="image/x-icon" />
	<link rel="shortcut icon" type="image/x-icon" href="assets/images/favicon.png" />
	
	<!-- PAGE TITLE HERE ============================================= -->
	<title>Stars Maritime Academy </title>
	
	<!-- MOBILE SPECIFIC ============================================= -->
	<meta name="viewport" content="width=device-width, initial-scale=1">
	
	<!--[if lt IE 9]>
	<script src="assets/js/html5shiv.min.js"></script>
	<script src="assets/js/respond.min.js"></script>
	<![endif]-->
	
	<!-- All PLUGINS CSS ============================================= -->
	<link rel="stylesheet" type="text/css" href="assets/css/assets.css">
	
	<!-- TYPOGRAPHY ============================================= -->
	<link rel="stylesheet" type="text/css" href="assets/css/typography.css">
	
	<!-- SHORTCODES ============================================= -->
	<link rel="stylesheet" type="text/css" href="assets/css/shortcodes/shortcodes.css">
	
	<!-- STYLESHEETS ============================================= -->
	<link rel="stylesheet" type="text/css" href="assets/css/style.css">
	<link class="skin" rel="stylesheet" type="text/css" href="assets/css/color/color-1.css">
	
	<!-- REVOLUTION SLIDER CSS ============================================= -->
	<link rel="stylesheet" type="text/css" href="assets/vendors/revolution/css/layers.css">
	<link rel="stylesheet" type="text/css" href="assets/vendors/revolution/css/settings.css">
	<link rel="stylesheet" type="text/css" href="assets/vendors/revolution/css/navigation.css">
	<!-- REVOLUTION SLIDER END -->	
</head>
<body id="bg">
<div class="page-wraper">
<!--<div id="loading-icon-bx"></div>-->
	<!-- Header Top ==== -->
    <?php include("inc/header.php"); ?>
    <!-- Header Top END ==== -->
    <!-- Content -->
    <div class="page-content bg-white">
        <!-- inner page banner -->
        <div class="page-banner ovbl-dark" style="background-image:url(assets/images/banner/banner1.jpg);">
            <div class="container">
                <div class="page-banner-entry">
                    <h1 class="text-white">Meet Our Instructor & Lecturers</h1>
				 </div>
            </div>
        </div>		
		<?php 
include("inc/db.php");

// Enable error reporting
error_reporting(E_ALL);
ini_set('display_errors', 1);

// Initialize the search term
$searchTerm = isset($_GET['search']) ? mysqli_real_escape_string($db, $_GET['search']) : '';

// Modify the query to include a search filter
$query = "SELECT * FROM staff_reg";
if ($searchTerm) {
    $query .= " WHERE fname LIKE '%$searchTerm%' OR dept LIKE '%$searchTerm%' OR cate LIKE '%$searchTerm%' OR design LIKE '%$searchTerm%' OR academic LIKE '%$searchTerm%' OR publi LIKE '%$searchTerm%'";
}
$result = mysqli_query($db, $query);
$serialNumber = 1;
?>
     <!-- Search Bar -->
	 <div class="row form-group">
        <div class="col-md-12">
            <form action="" method="GET">
                <input type="text" name="search" class="form-control" placeholder="Search for names, department, etc." value="<?php echo htmlspecialchars($searchTerm); ?>">
                <button type="submit" class="btn btn-primary mt-2">Search</button>
            </form>
        </div>
    </div>
    
    <!-- Staff Data Table -->
    <table class="table table-bordered">
        <thead>
            <tr>
                <th>Serial Number</th>
                <th>Image</th>
                <th>Full Name</th>
                <th>Department</th>
                <th>Category</th>
                <th>Designation</th>
                <th>Academic Qualification</th>
                <th>Publication</th>
                <th>View</th>
            </tr>
        </thead>
        <tbody>
            <?php
            if (mysqli_num_rows($result) > 0) {
                while ($row = mysqli_fetch_assoc($result)) {
                    echo "<tr>
                        <td>{$serialNumber}</td>
                        <td><img src='uploads/{$row['good']}' alt='Passport' width='50' height='50'></td>
                        <td>{$row['fname']}</td>
                        <td>{$row['dept']}</td>
                        <td>{$row['cate']}</td>
                        <td>{$row['design']}</td>
                        <td>{$row['academic']}</td>
                        <td>{$row['publi']}</td>
                        <td><a href='staff_profi.php?id={$row['id']}' class='btn btn-info btn-sm'>View Profile</a></td>
                    </tr>";
                    $serialNumber++;
                }
            } else {
                echo "<tr><td colspan='9' align='center'>No data found</td></tr>";
            }
            ?>
        </tbody>
    </table>
</div> 
<!-- end table -->

	<!-- Footer ==== -->
<?php include("inc/footer.php"); ?>
