<?php
require_once 'db.php';

header('Content-Type: application/json');

$categoryId = $_GET['category_id'] ?? 0;

$stmt = $pdo->prepare("SELECT r.id, r.room_number, c.price 
                       FROM rooms r
                       JOIN room_categories c ON r.category_id = c.id
                       WHERE r.category_id = ? AND r.status = 'available'");
$stmt->execute([$categoryId]);

echo json_encode($stmt->fetchAll(PDO::FETCH_ASSOC));
