File "read_courses.php"

Full path: /home2/santhos2/public_html/bharath-coe.firstmatrix.in.net/api/internal_marks/read_courses.php
File size: 576 B
MIME-type: text/x-php
Charset: utf-8

Download   Open   Back

<?php
require_once __DIR__ . '/../../config/config.php';
header('Content-Type: application/json');
ob_start();
try {
    global $pdo;
    $stmt = $pdo->query("SELECT course_id, course_name FROM courses WHERE status='Active' ORDER BY course_name");
    $data = $stmt->fetchAll(PDO::FETCH_ASSOC);
    echo json_encode(['status'=>'success','data'=>$data]);
} catch (Throwable $e) {
    error_log('read_courses error: '.$e->getMessage());
    http_response_code(500);
    echo json_encode(['status'=>'error','message'=>$e->getMessage()]);
}
ob_end_flush();
?>


PHP File Manager