0) {
// Fetch product data to get the icon and image paths
$result = mysqli_query($conn, "SELECT icon, image FROM products WHERE id = $id");
if ($result && mysqli_num_rows($result) > 0) {
$row = mysqli_fetch_assoc($result);
$icon_path = 'assets/images/product_icons/' . basename($row['icon']);
$image_path = 'assets/images/product_images/' . basename($row['image']);
// Prepare SQL DELETE statements
$delete_product_sql = "DELETE FROM products WHERE id = $id";
// Execute the SQL statement
if (mysqli_query($conn, $delete_product_sql)) {
// Remove the product icon and image from the directory
if (file_exists($icon_path)) {
unlink($icon_path);
}
if (file_exists($image_path)) {
unlink($image_path);
}
echo "";
} else {
echo "";
}
} else {
echo "";
}
} else {
echo "";
}
} else {
echo "";
}
mysqli_close($conn);
?>