<?php
require_once "../database.php";
header('Content-Type: application/json');

$id = $_POST['id'] ?? null;
$status = $_POST['status'] ?? null;

if ($id && $status) {
    $stmt = $conn->prepare("UPDATE news SET status = ? WHERE id = ?");
    $success = $stmt->execute([$status, $id]);

    echo json_encode([
        "status" => $success ? "success" : "error",
        "message" => $success ? "Status updated" : "Update failed"
    ]);
} else {
    echo json_encode(["status" => "error", "message" => "Missing parameters"]);
}
?>
