File "read_single_ci_setting.php"

Full path: /home2/santhos2/public_html/bharath-coe.firstmatrix.in.net/api/internal_marks/read_single_ci_setting.php
File size: 1.08 KiB (1105 bytes)
MIME-type: text/x-php
Charset: utf-8

Download   Open   Back

<?php
require_once __DIR__ . '/../../config/config.php';
require_once __DIR__ . '/../../config/db.php';

header('Content-Type: application/json');

try {
    if (!isset($_GET['id'])) {
        echo json_encode(['status' => 'error', 'message' => 'Setting ID is required']);
        exit;
    }
    
    $setting_id = intval($_GET['id']);
    
    $stmt = $pdo->prepare("
        SELECT 
            cas.*,
            c.course_name,
            c.course_code
        FROM ci_assessment_settings cas
        JOIN courses c ON cas.course_id = c.course_id
        WHERE cas.setting_id = ?
    ");
    
    $stmt->execute([$setting_id]);
    $setting = $stmt->fetch(PDO::FETCH_ASSOC);
    
    if (!$setting) {
        echo json_encode([
            'status' => 'error',
            'message' => 'CI assessment setting not found'
        ]);
        exit;
    }
    
    echo json_encode([
        'status' => 'success',
        'data' => $setting
    ]);
    
} catch (Exception $e) {
    echo json_encode([
        'status' => 'error',
        'message' => 'Database error: ' . $e->getMessage()
    ]);
}
?>

PHP File Manager