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

$id = $_GET['id'] ?? null;

if ($id) {
    $stmt = $conn->prepare("DELETE FROM news WHERE id = ?");
    $success = $stmt->execute([$id]);

    echo json_encode([
        "status" => $success ? "success" : "error",
        "message" => $success ? "News deleted" : "Deletion failed"
    ]);
} else {
    echo json_encode(["status" => "error", "message" => "No ID provided"]);
}
?>
