0% found this document useful (0 votes)
20 views5 pages

Employee - List Final

The document is a PHP script that displays an employee list for a payroll system. It checks for user session validity, connects to a MySQL database to fetch employee data, and presents it in a styled HTML table. The sidebar provides navigation options, and there are buttons for adding new employees and performing actions like viewing, editing, or deleting employee records.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views5 pages

Employee - List Final

The document is a PHP script that displays an employee list for a payroll system. It checks for user session validity, connects to a MySQL database to fetch employee data, and presents it in a styled HTML table. The sidebar provides navigation options, and there are buttons for adding new employees and performing actions like viewing, editing, or deleting employee records.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 5

<?

php
if (isset($_SESSION['message'])) {
echo "<div class='message'>" . $_SESSION['message'] . "</div>";
unset($_SESSION['message']);
}
?>

<?php
session_start();
if (!isset($_SESSION['username'])) {
header('Location: login.php');
exit;
}

// Database connection
$conn = new mysqli('localhost', 'root', '', 'payroll_system');
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}

// Fetch employees from the database


$sql = "SELECT employee_id, CONCAT(first_name, ' ', last_name) AS full_name,
position, project_name, project_location FROM employees";
$result = $conn->query($sql);
?>

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Employee List - Payroll System</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}

body {
font-family: 'Arial', sans-serif;
background-color: #f0f2f5;
display: flex;
min-height: 100vh;
}

.sidebar {
width: 250px;
background: linear-gradient(135deg, #007bff, #0056b3);
color: #fff;
height: 100vh;
position: fixed;
padding: 20px;
}

.sidebar h2 {
font-size: 24px;
margin-bottom: 20px;
text-align: center;
}

.sidebar ul {
list-style: none;
padding: 0;
}

.sidebar ul li {
margin: 15px 0;
}

.sidebar ul li a {
color: #fff;
text-decoration: none;
font-size: 18px;
display: block;
padding: 10px;
border-radius: 5px;
}

.sidebar ul li a:hover {
background-color: #0056b3;
}

.content {
margin-left: 270px;
padding: 40px;
flex: 1;
}

.content h1 {
font-size: 28px;
margin-bottom: 20px;
color: #333;
}

.button-container {
margin-bottom: 20px;
}

.button-container a button {
padding: 10px 15px;
background-color: #28a745;
color: white;
border: none;
border-radius: 5px;
font-size: 16px;
cursor: pointer;
}

.button-container a button:hover {
background-color: #218838;
}

table {
width: 100%;
border-collapse: collapse;
margin-top: 20px;
}

table, th, td {
border: 1px solid #ddd;
}

th, td {
padding: 12px;
text-align: left;
}

th {
background-color: #007bff;
color: white;
}

tr:nth-child(even) {
background-color: #f2f2f2;
}

.action-btns a {
text-decoration: none;
padding: 5px 10px;
background-color: #007bff;
color: white;
border-radius: 5px;
}

.action-btns a:hover {
background-color: #0056b3;
}

.message, .error {
margin-top: 20px;
}
</style>
</head>
<body>
<!-- Sidebar -->
<div class="sidebar">
<h2>Payroll System</h2>
<ul>
<li><a href="dashboard.php">Dashboard</a></li>
<li><a href="employee_list.php">Employee List</a></li>
<li><a href="#">Payroll List</a></li>
<li><a href="department_list.php">Department Lists</a></li>
<li><a href="position_list.php">Position Lists</a></li>
<li><a href="allowance_list.php">Allowance Lists</a></li>
<li><a href="deduction_list.php">Deduction Lists</a></li>
<li><a href="projects.php">Project Lists</a></li>
<li><a href="attendance_list.php">Attendance</a></li>
<li><a href="list_users.php">Admin Account Lists</a></li>
<li><a href="logout.php">Logout</a></li>
</ul>
</div>

<!-- Main Content -->


<div class="content">
<h1>Employee List</h1>
<div class="button-container">
<a href="add_employee.php"><button>Add New Employee</button></a>
</div>

<?php if ($result->num_rows > 0): ?>


<table>
<thead>
<tr>
<th>Employee ID</th>
<th>Full Name</th>
<th>Position</th>
<th>Project Name</th>
<th>Project Location</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<?php while ($row = $result->fetch_assoc()): ?>
<tr>
<td><?php echo $row['employee_id']; ?></td>
<td><?php echo $row['full_name']; ?></td>
<td><?php echo $row['position']; ?></td>
<td><?php echo $row['project_name']; ?></td>
<td><?php echo $row['project_location']; ?></td>

<td class="action-btns">

<a href="view_employee.php?employee_id=<?php echo


$row['employee_id']; ?>">View/Edit</a>
<!-- <a href="edit_employee.php?employee_id=<?php echo $row['employee_id']; ?
>">Edit</a> -->
<a href="delete_employee.php?employee_id=<?php echo $row['employee_id']; ?>"
onclick="return confirm('Are you sure you want to delete this
employee?')">Delete</a>
</td>

</tr>
<?php endwhile; ?>
</tbody>
</table>
<?php else: ?>
<p>No employees found.</p>
<?php endif; ?>

<?php
// Close the database connection
$conn->close();
?>
</div>
</body>
</html>

You might also like