File "get_exam_dates.php"

Full path: /home2/santhos2/public_html/bharath-coe.firstmatrix.in.net/api/exam_attendance/get_exam_dates.php
File size: 1.32 KiB (1352 bytes)
MIME-type: text/x-php
Charset: utf-8

Download   Open   Back

<?php
header('Content-Type: application/json');
require_once '../../config/config.php';

try {
    $academicYear = $_GET['academic_year'] ?? '';
    $examTypeId = $_GET['exam_type_id'] ?? '';
    
    if (empty($academicYear) || empty($examTypeId)) {
        echo json_encode([
            'success' => false,
            'message' => 'Academic year and exam type are required'
        ]);
        exit;
    }
    
    // Get unique exam dates from exam_timetable for the selected academic year and type
    $sql = "
        SELECT DISTINCT et.exam_date
        FROM exam_timetable et
        INNER JOIN exam_subjects es ON et.exam_subject_id = es.exam_subject_id
        INNER JOIN exams e ON es.exam_id = e.exam_id
        WHERE e.academic_year = :academic_year 
        AND e.exam_type_id = :exam_type_id
        ORDER BY et.exam_date ASC
    ";
    
    $stmt = $pdo->prepare($sql);
    $stmt->bindParam(':academic_year', $academicYear);
    $stmt->bindParam(':exam_type_id', $examTypeId);
    $stmt->execute();
    
    $dates = $stmt->fetchAll(PDO::FETCH_ASSOC);
    
    echo json_encode([
        'status' => 'success',
        'data' => $dates
    ]);
    
} catch (Exception $e) {
    echo json_encode([
        'status' => 'error',
        'message' => 'Error: ' . $e->getMessage()
    ]);
}
?>

PHP File Manager