File "read.php"
Full path: /home2/santhos2/public_html/bharath-coe.firstmatrix.in.net/api/co_po_mapping/read.php
File size: 783 B
MIME-type: text/x-php
Charset: utf-8
<?php
require_once '../../config/config.php';
header('Content-Type: application/json');
try {
$stmt = $pdo->query("SELECT m.mapping_id, m.subject_id, m.co_code, m.po_codes, sub.subject_name, sub.subject_code
FROM co_po_mapping m
JOIN subjects sub ON m.subject_id = sub.subject_id
ORDER BY m.mapping_id DESC");
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
// Decode JSON for convenience
foreach ($rows as &$r) {
$r['po_codes'] = json_decode($r['po_codes'], true);
}
echo json_encode(['status'=>'success','data'=>$rows]);
} catch (Throwable $e) {
http_response_code(500);
echo json_encode(['status'=>'error','message'=>$e->getMessage()]);
}
?>