<?php
require_once "../db.php";

$id = $_GET['id'];

// delete image file first
$res = $conn->query("SELECT image FROM merch_items WHERE id=$id");
$row = $res->fetch_assoc();

if($row && $row['image']){
    @unlink("uploads/".$row['image']);
}

$conn->query("DELETE FROM merch_items WHERE id=$id");

echo json_encode(["success"=>true]);
