Files
sam-kd/guiderail/fetch_guiderail_detail.php

32 lines
956 B
PHP
Raw Normal View History

<?php
require_once($_SERVER['DOCUMENT_ROOT'] . "/session.php");
require_once($_SERVER['DOCUMENT_ROOT'] . "/lib/mydb.php");
$pdo = db_connect();
$num = isset($_POST['num']) ? intval($_POST['num']) : 0;
if ($num <= 0) {
echo json_encode(['error' => '유효하지 않은 번호입니다.']);
exit;
}
try {
$sql = "SELECT * FROM {$DB}.guiderail WHERE num = ? AND is_deleted IS NULL";
$stmt = $pdo->prepare($sql);
$stmt->bindValue(1, $num, PDO::PARAM_INT);
$stmt->execute();
$row = $stmt->fetch(PDO::FETCH_ASSOC);
if ($row) {
// JSON 응답으로 반환
header('Content-Type: application/json; charset=utf-8');
echo json_encode($row, JSON_UNESCAPED_UNICODE);
} else {
echo json_encode(['error' => '해당 데이터를 찾을 수 없습니다.']);
}
} catch (PDOException $Exception) {
echo json_encode(['error' => '데이터베이스 오류: ' . $Exception->getMessage()]);
}
?>