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

if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $categoryId = $_POST['category_id'];
    $status = $_POST['status'];

    $stmt = $pdo->prepare("UPDATE topics SET status = ? WHERE category_id = ?");
    $success = $stmt->execute([$status, $categoryId]);

    echo json_encode([
        'status' => $success ? 'success' : 'error',
        'message' => $success ? 'Status updated successfully' : 'Failed to update status'
    ]);
} else {
    echo json_encode(['status' => 'error', 'message' => 'Invalid request method']);
}
?>