File "read_single.php"
Full path: /home2/santhos2/public_html/bharath-coe.firstmatrix.in.net/api/halls/read_single.php
File size: 726 B
MIME-type: text/x-php
Charset: utf-8
<?php
require_once '../../config/config.php';
header('Content-Type: application/json');
try {
$id = isset($_GET['id']) ? (int)$_GET['id'] : 0;
if ($id <= 0) { echo json_encode(['status'=>'error','message'=>'Invalid id']); exit; }
$stmt = $pdo->prepare('SELECT hall_id, college_id, hall_name, block_name, capacity FROM halls WHERE hall_id = ?');
$stmt->execute([$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()]);
}
?>