I made a database (php/mysql) with photos and descriptions. Everything works well. I can remove the entire record (4 pictures and descriptions) but do not know how to remove only one picture to remain eg 3. Thank you in advance for your help
delete.php
<?php
// 2. Perform database query
$id = $photo["id"];
$safe_page_id = mysqli_real_escape_string($connection, $id);
$query = "DELETE FROM photographs ";
$query .= "WHERE id = {$id} ";
$query .= "LIMIT 1";
$result = mysqli_query($connection, $query);
if ($result && mysqli_affected_rows($connection) == 1) {
// Success
$_SESSION["message"] = "product removed.";
redirect_to("list_photos_46.php");
echo "Success!";
} else {
// Failure
$_SESSION["message"] = "Failure.";
redirect_to("list_photos_46.php?page={$id}");
die("Database query failed. " . mysqli_error($connection));
}
?>
list_photos.php - deletes all pictures and descriptions
<td><a href="delete_photo_2.php?id=<?php echo urlencode($row['id']); ?>"onclick="return confirm('are you sure? ');">{Delete}</a></td>