<?php
include '../includes/config.php';


if (isset($_GET['id'])) {
    $category_id = $_GET['id'];

    $sql = "DELETE FROM expense_category WHERE id = :id";
    $stmt = $conn->prepare($sql);
    $stmt->bindParam(':id', $category_id, PDO::PARAM_INT);

    if ($stmt->execute()) {
        echo "<script>
                alert('Category deleted successfully!');
                window.location.href = '../list_expense_category.php';
              </script>";
    } else {
        echo "<script>
                alert('Error deleting category.');
              </script>";
    }
} else {
    header('Location: ../list_expense_category.php');
}
?>
