The Attendance Tracking system provides comprehensive monitoring and management of student attendance. Teachers can view real-time attendance for current classes, update statuses manually, view statistics, and access historical records. Students can monitor their own attendance history and check-in records.
Shows entire class roster, not just present students
Default Absent
Students without scans shown as absent
Timestamp Display
Shows exact time of attendance check-in
The system uses a LEFT JOIN to ensure all enrolled students appear in the attendance list, even those who haven’t checked in yet. Students without attendance records automatically show as “Absent”.
Teachers can manually update attendance statuses directly from the dashboard. This is useful for correcting errors or manually marking students present/late/absent.
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['update_status'])) { $attendance_id = $_POST['attendance_id']; $new_status = $_POST['new_status']; // Verify teacher has permission to update this attendance record $verify_stmt = $pdo->prepare(" SELECT a.id FROM attendance a JOIN classes c ON a.class_id = c.id WHERE a.id = ? AND c.teacher_id = ? "); $verify_stmt->execute([$attendance_id, $teacher_id]); if ($verify_stmt->rowCount() > 0) { $update_stmt = $pdo->prepare(" UPDATE attendance SET status = ? WHERE id = ? "); $update_stmt->execute([$new_status, $attendance_id]); $_SESSION['success'] = "Attendance status updated successfully"; } else { $_SESSION['error'] = "You don't have permission to modify this attendance record"; }}
$stmt = $pdo->prepare(" SELECT a.*, c.name as class_name, t.name as teacher_name FROM attendance a LEFT JOIN classes c ON a.class_id = c.id LEFT JOIN teachers t ON c.teacher_id = t.teacher_id WHERE a.student_id = ? ORDER BY a.date DESC, a.time DESC LIMIT 10");$stmt->execute([$student['student_id']]);
$stmt = $pdo->prepare("SELECT COUNT(*) as total_attendance, COUNT(DISTINCT DATE(date)) as days_attended, MAX(date) as last_attendance FROM attendance WHERE student_id = ?");$stmt->execute([$student['student_id']]);$stats = $stmt->fetch();
// Check if attendance already marked$stmt = $pdo->prepare(" SELECT * FROM attendance WHERE student_id = ? AND class_id = ? AND date = CURRENT_DATE()");$stmt->execute([$student_id, $student['class_id']]);
if ($stmt->rowCount() == 0) { // Mark attendance} else { echo "⚠️ Attendance already marked for this class today";}
If a student scans their QR code multiple times in the same day for the same class, the system displays a warning message and does not create a duplicate record. The original attendance record remains unchanged.
Cause: Student already scanned for this class todaySolution: No action needed - original record is preserved. Use status update if time needs correction.