File "debug_subjects.php"

Full path: /home2/santhos2/public_html/bharath-coe.firstmatrix.in.net/api/exam_subjects/debug_subjects.php
File size: 1.16 KiB (1183 bytes)
MIME-type: text/x-php
Charset: utf-8

Download   Open   Back

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

try {
    // Get all subjects with course and semester info
    $sql = "SELECT s.subject_id, s.subject_name, s.subject_code, s.semester, s.course_id, c.course_name
            FROM subjects s
            LEFT JOIN courses c ON c.course_id = s.course_id
            ORDER BY c.course_name, s.semester, s.subject_name";
    
    $stmt = $pdo->prepare($sql);
    $stmt->execute();
    $subjects = $stmt->fetchAll(PDO::FETCH_ASSOC);
    
    // Get all exams
    $examSql = "SELECT exam_id, exam_name, academic_year, semester, status FROM exams ORDER BY exam_id DESC";
    $examStmt = $pdo->prepare($examSql);
    $examStmt->execute();
    $exams = $examStmt->fetchAll(PDO::FETCH_ASSOC);
    
    echo json_encode([
        'success' => true,
        'total_subjects' => count($subjects),
        'total_exams' => count($exams),
        'subjects' => $subjects,
        'exams' => $exams
    ]);
    
} catch (Exception $e) {
    echo json_encode(['success' => false, 'message' => 'Database error: ' . $e->getMessage()]);
}
?>



















PHP File Manager