<?php
header("Content-Type: application/json");
require("../../includes/config.php");

try {
    // Fetch active streams
    $stmt = $pdo->prepare("SELECT id, stream_name FROM streams WHERE status = 1 ORDER BY stream_name ASC");
    $stmt->execute();
    $streams = $stmt->fetchAll(PDO::FETCH_ASSOC);

    echo json_encode($streams);
} catch (PDOException $e) {
    http_response_code(500);
    echo json_encode(['error' => 'Database failure']);
}
?>