query("SELECT * FROM students WHERE id = $student_id")->fetch_assoc(); if (!$student) { header('Location: students.php'); exit; } $page_title = 'View Student - ' . $student['student_name']; $page_subtitle = 'Complete student information'; $current_user = getCurrentUser(); // Get all marks for student $marks = $conn->query(" SELECT s.subject_name, s.subject_name_pb, m.marks_obtained, s.max_marks, m.exam_year, m.exam_type, s.passing_marks FROM marks m JOIN subjects s ON m.subject_id = s.id WHERE m.student_id = $student_id ORDER BY m.exam_year DESC, FIELD(m.exam_type, 'Annual', 'Half Yearly', 'Supplementary'), s.subject_name "); // Get certificates for student $certificates = $conn->query(" SELECT * FROM certificates WHERE student_id = $student_id ORDER BY issue_date DESC "); // Calculate overall statistics $total_marks = 0; $total_max = 0; $subject_count = 0; $passed_subjects = 0; $marks_data = $conn->query(" SELECT m.marks_obtained, s.max_marks, s.passing_marks FROM marks m JOIN subjects s ON m.subject_id = s.id WHERE m.student_id = $student_id AND m.exam_type = 'Annual' AND m.exam_year = 2024 "); while($row = $marks_data->fetch_assoc()) { $total_marks += $row['marks_obtained']; $total_max += $row['max_marks']; $subject_count++; if ($row['marks_obtained'] >= $row['passing_marks']) { $passed_subjects++; } } $percentage = $total_max > 0 ? ($total_marks / $total_max) * 100 : 0; $result_status = $passed_subjects == $subject_count ? 'PASS' : 'FAIL'; $division = ''; if ($result_status == 'PASS') { if ($percentage >= 75) $division = 'Distinction'; elseif ($percentage >= 60) $division = 'First Division'; elseif ($percentage >= 45) $division = 'Second Division'; elseif ($percentage >= 33) $division = 'Third Division'; } include 'includes/header.php'; include 'includes/sidebar.php'; ?>
| Subject | ਵਿਸ਼ਾ | Max Marks | Passing Marks | Marks Obtained | Percentage | Result |
|---|---|---|---|---|---|---|
| % | PASS FAIL |
No certificates issued yet