$tmp_name) { $file_name = basename($_FILES['multiple_images']['name'][$key]); $target_dir = "assets/img/gallery/"; $target_file = $target_dir . $file_name; if (move_uploaded_file($tmp_name, $target_file)) { $title = mysqli_real_escape_string($con, $titles[$key]); $sql = "INSERT INTO inner_banner (image, title) VALUES ('$file_name', '$title')"; mysqli_query($con, $sql); } } $alert = 'Images added successfully.'; $alert_class = 'alert-success'; } else { $alert = 'Error: No images were uploaded.'; $alert_class = 'alert-danger'; } } // Delete Image if (isset($_POST['action']) && $_POST['action'] === 'delete') { $id = mysqli_real_escape_string($con, $_POST['id']); $sql = "SELECT image FROM inner_banner WHERE id = $id"; $result = mysqli_query($con, $sql); $row = mysqli_fetch_assoc($result); if ($row) { $image_path = "assets/img/gallery/" . $row['image']; if (file_exists($image_path)) unlink($image_path); $sql = "DELETE FROM inner_banner WHERE id = $id"; if (mysqli_query($con, $sql)) { $alert = 'Image deleted successfully.'; $alert_class = 'alert-success'; } else { $alert = 'Error: ' . mysqli_error($con); $alert_class = 'alert-danger'; } } else { $alert = 'Error: Image not found.'; $alert_class = 'alert-danger'; } } } // Fetch All Slider Images function fetchSliderImages($con) { $sql = "SELECT * FROM inner_banner ORDER BY created_at DESC"; $result = mysqli_query($con, $sql); $images = []; while ($row = mysqli_fetch_assoc($result)) { $images[] = $row; } return $images; } ?> Image Slider
$img): ?>
# Image Title Action
<?= htmlspecialchars($img['title']) ?>