0) { // Fetch the category data to get the icon path $result = mysqli_query($conn, "SELECT c_icon FROM categories WHERE id = $id"); if ($result && mysqli_num_rows($result) > 0) { $row = mysqli_fetch_assoc($result); $icon_path = $row['c_icon']; // Prepare the SQL DELETE statements $delete_category_sql = "DELETE FROM categories WHERE id = $id"; $delete_products_sql = "DELETE FROM products WHERE category_id = $id"; // Execute the SQL statements if (mysqli_query($conn, $delete_products_sql) && mysqli_query($conn, $delete_category_sql)) { // Remove the category icon from the directory if (file_exists($icon_path)) { unlink($icon_path); } echo ""; } else { echo ""; } } else { echo ""; } } else { echo ""; } } else { echo ""; } // Close the database connection mysqli_close($conn); ?>