<?php
include 'db.php';
header('Content-Type: application/json');

$stmt = $pdo->prepare("
    SELECT id, name, category_id, status 
    FROM topics 
    ORDER BY category_id, name
");
$stmt->execute();
$topics = $stmt->fetchAll(PDO::FETCH_ASSOC);

echo json_encode($topics);
?>