File "read_single.php"

Full path: /home2/santhos2/public_html/bharath-coe.firstmatrix.in.net/api/question_paper_orders/read_single.php
File size: 1.51 KiB (1546 bytes)
MIME-type: text/x-php
Charset: utf-8

Download   Open   Back

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

try {
    $order_id = isset($_GET['id']) ? (int)$_GET['id'] : 0;
    if ($order_id <= 0) { echo json_encode(['status'=>'error','message'=>'Invalid id']); exit; }

    $sql = "SELECT qpo.order_id, qpo.exam_subject_id, qpo.setter_id, qpo.status, qpo.time_duration,
                   qpo.approver_id, qpo.approved_at, qpo.final_pattern_id,
                   e.exam_name, e.academic_year, e.semester,
                   sub.subject_name, sub.subject_code,
                   setter.first_name AS setter_first, setter.last_name AS setter_last,
                   appr.first_name AS approver_first, appr.last_name AS approver_last
            FROM question_paper_orders qpo
            JOIN exam_subjects es ON qpo.exam_subject_id = es.exam_subject_id
            JOIN exams e ON es.exam_id = e.exam_id
            JOIN subjects sub ON es.subject_id = sub.subject_id
            LEFT JOIN staff setter ON qpo.setter_id = setter.staff_id
            LEFT JOIN staff appr ON qpo.approver_id = appr.staff_id
            WHERE qpo.order_id = ?";
    $stmt = $pdo->prepare($sql);
    $stmt->execute([$order_id]);
    $row = $stmt->fetch(PDO::FETCH_ASSOC);
    if (!$row) { echo json_encode(['status'=>'error','message'=>'Not found']); exit; }
    echo json_encode(['status'=>'success','data'=>$row]);
} catch (Throwable $e) {
    http_response_code(500);
    echo json_encode(['status'=>'error','message'=>$e->getMessage()]);
}
?>


PHP File Manager