Edit Marksheet
Student: = htmlspecialchars($student['student_name']) ?> | Roll: = $student['roll_no'] ?>
$m) { $sub_id = intval($subject_id); $theory = intval($m['theory']); $practical = intval($m['practical']); $sql = "INSERT INTO marks (student_id, subject_id, marks_obtained, practical_marks, exam_year, exam_type, date_of_issue) VALUES (?, ?, ?, ?, ?, ?, ?) ON DUPLICATE KEY UPDATE marks_obtained = VALUES(marks_obtained), practical_marks = VALUES(practical_marks), date_of_issue = VALUES(date_of_issue), exam_year = VALUES(exam_year), exam_type = VALUES(exam_type)"; $stmt = $conn->prepare($sql); $stmt->bind_param("iiiiiss", $student_id, $sub_id, $theory, $practical, $exam_year, $exam_type, $date_of_issue); if (!$stmt->execute()) { die("SQL Error: " . $stmt->error); } $stmt->close(); } $_SESSION['success_msg'] = "Marksheet Updated Successfully!"; header("Location: marksheet_manager.php"); exit(); } // Data fetch $student = $conn->query("SELECT student_name, roll_no, class FROM students WHERE id = $student_id")->fetch_assoc(); if (!$student) { die("Student not found!"); } $class = $student['class']; $query = "SELECT s.id as subject_id, s.subject_name, s.max_marks, m.marks_obtained, m.practical_marks, m.exam_year, m.exam_type, m.date_of_issue FROM subjects s LEFT JOIN marks m ON s.id = m.subject_id AND m.student_id = $student_id WHERE s.class = '$class'"; $marks_res = $conn->query($query); $first = $conn->query("SELECT exam_year, exam_type, date_of_issue FROM marks WHERE student_id = $student_id LIMIT 1")->fetch_assoc(); $default_year = $first['exam_year'] ?? date('Y'); $default_type = $first['exam_type'] ?? 'Annual'; $default_date = $first['date_of_issue'] ?? date('Y-m-d'); $page_title = "Edit Marksheet"; include 'includes/header.php'; include 'includes/sidebar.php'; ?>
Student: = htmlspecialchars($student['student_name']) ?> | Roll: = $student['roll_no'] ?>