File "read_select.php"

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

Download   Open   Back

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

try {
    $sql = "SELECT course_id, course_code, course_name, regulation_year FROM courses WHERE status = 'Active' ORDER BY course_name ASC";
    $stmt = $pdo->query($sql);
    $courses = $stmt->fetchAll(PDO::FETCH_ASSOC);
    
    echo json_encode([
        'status' => 'success',
        'data' => $courses
    ]);
} catch (Throwable $e) {
    http_response_code(500);
    echo json_encode([
        'status' => 'error',
        'message' => $e->getMessage()
    ]);
}
?>

PHP File Manager