<?php
include 'includes/db.php';
$id = intval($_GET['id']);
$car_id = intval($_GET['car_id']);
$photo = $conn->query("SELECT filename FROM car_photos WHERE id = $id")->fetch_assoc();
if ($photo) {
    unlink('uploads/' . $photo['filename']);
    $conn->query("DELETE FROM car_photos WHERE id = $id");
}
header("Location: edit_car.php?id=$car_id");
?>