I have a system to publish articles with images, but when deleting the article, it deletes only one image and not all the images that were uploaded from that article.
<?php
include('assets/system/core.php');
$id = $_GET['id'];
$consulta = mysqli_query($db, "SELECT * FROM images WHERE id2 = '$id' ");
$registro = mysqli_fetch_assoc($consulta);
$ruta = $registro['file_name'];
unlink("uploads/".$ruta);
$query = mysqli_query($db,"DELETE FROM amenidades WHERE id = '$id'");
$query2 = mysqli_query($db,"DELETE FROM images WHERE id2 = '$id'");
$query3 = mysqli_query($db,"DELETE FROM propiedades WHERE id = '$id'");
$query4 = mysqli_query($db,"DELETE FROM visit_days WHERE id = '$id'");
$query4 = mysqli_query($db,"DELETE FROM comments WHERE prpdad_id = '$id'");
header("LOCATION: ".$web_settings['weblink']."mispropiedades.php");
How could I delete all the images corresponding to a record from my database?
source https://stackoverflow.com/questions/77334581/how-can-i-delete-multiple-images-based-on-an-id-of-a-record-from-a-table
No comments:
Post a Comment