31 lines
708 B
PHP
31 lines
708 B
PHP
|
|
|
|
<?php
|
|
$rootPath = dirname(dirname(__DIR__));
|
|
require_once($rootPath . "/src/config/connection.php");
|
|
|
|
if (isset($_GET['tab_id'])) {
|
|
$tab_id = (int) $_GET['tab_id']; // Convert to integer
|
|
|
|
if ($tab_id <= 0) {
|
|
echo json_encode(['status' => 'error', 'message' => 'Invalid tab ID.']);
|
|
exit();
|
|
}
|
|
|
|
// Fetch drinks available for this tab
|
|
$stmt = $conn->prepare("SELECT * FROM bar_items");
|
|
$stmt->execute();
|
|
$result = $stmt->get_result();
|
|
|
|
$drinks = [];
|
|
while ($row = $result->fetch_assoc()) {
|
|
$drinks[] = $row;
|
|
}
|
|
|
|
echo json_encode($drinks);
|
|
} else {
|
|
echo json_encode(['status' => 'error', 'message' => 'Tab ID is required.']);
|
|
}
|
|
?>
|
|
|