File: //home/jibhires/d1.brightsolutionsindia.com/attendence.php
<?php
// Database connection
$conn = new mysqli("localhost", "jibhires_syrma", "0*YzVc5}%l){", "employee_attendance");
$date = date("Y-m-d");
// Process attendance submission
if ($_SERVER["REQUEST_METHOD"] == "POST") {
foreach ($_POST["attendance"] as $employee_id => $status) {
$sql = "INSERT INTO attendance (employee_id, date, status)
VALUES ($employee_id, '$date', '$status')
ON DUPLICATE KEY UPDATE status='$status'";
$conn->query($sql);
}
echo "<p>Attendance updated successfully!</p>";
}
// Get all employees
$employees = $conn->query("SELECT * FROM employees ORDER BY section, level");
?>
<!DOCTYPE html>
<html>
<head>
<title>Daily Attendance</title>
<style>
table { border-collapse: collapse; width: 100%; }
th, td { border: 1px solid #ddd; padding: 8px; text-align: left; }
th { background-color: #f2f2f2; }
</style>
</head>
<body>
<h1>Daily Attendance - <?= date("d/m/Y") ?></h1>
<form method="post">
<table>
<tr>
<th>Name</th>
<th>Section</th>
<th>Level</th>
<th>Status</th>
</tr>
<?php while($row = $employees->fetch_assoc()): ?>
<tr>
<td><?= $row["name"] ?></td>
<td><?= $row["section"] ?></td>
<td><?= $row["level"] ?></td>
<td>
<select name="attendance[<?= $row['id'] ?>]">
<option value="Present">Present</option>
<option value="Planned Leave">Planned Leave</option>
<option value="Unplanned Leave">Unplanned Leave</option>
</select>
</td>
</tr>
<?php endwhile; ?>
</table>
<button type="submit">Submit Attendance</button>
</form>
</body>
</html>