File Name: ".$image['imagename']."
"; echo "Upload Date: ".$image['upload']."
"; ?>ID: ".$row['id']."
"; echo ""; echo ""; // Check if query is set if (isset($_GET['d'])) { // Get all image detail $delete_select = "SELECT * FROM swag_table WHERE id = ".$_GET['d']; $delete_result = mysqli_query($conn,$delete_select); $img_records = mysqli_fetch_assoc($delete_result); // Get image name and its file path $file_name = $img_records['imagename']; $file_path = "images/".$file_name; // Try deleting image if(unlink($file_path)) { // If deleted, delete from Table $img_delete_request = "DELETE FROM swag_table WHERE id =".$img_records[id]; $img_delete = mysqli_query($conn,$img_delete_request); if ($img_delete) { // Deleted image echo "Successfully deleted: ".$file_name."/".$_GET['d']."
"; } }else{ // Could not delete from file echo "Failed to delete or no file under the name: ".$file_name." ".$_GET['d']."
"; } } ?>