<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="gallery.css"> <!-- Add your CSS file for styling here -->
    <title>Image Gallery</title>
</head>
<body>
    <h1>Image Gallery</h1>
    <div class="image-gallery" id="imageGallery">
        <?php
        // Include the fetch_gallery_image.php file
        include('fetch_gallery_image.php');

        // Fetch image data from fetch_gallery_image.php
        $imageData = fetchImageGalleryData();

        // Display the gallery
        if (!empty($imageData)) {
            foreach ($imageData as $item) {
                echo '<div class="image-card" onclick="openFullscreen(\'' . $item['image_url'] . '\', \'' . $item['title'] . '\', \'' . $item['description'] . '\')">';
                echo '<img src="' . $item['image_url'] . '" alt="' . $item['title'] . '">';
                echo '<div class="image-info">';
                echo '<h2>' . $item['title'] . '</h2>';
                echo '<p>' . $item['description'] . '</p>';
                echo '</div>';
                echo '</div>';
            }
            
        } else {
            echo '<p>No images found in the database.</p>';
        }
        ?>
    </div>

    <!-- Full-screen image view -->
    <div class="fullscreen-image" id="fullscreenImage">
        <button id="closeButton" onclick="closeFullscreen()">&#10006; Close</button>
        <div class="image-nav">
            <button onclick="prevImage()">&#8249; Previous</button>
            <button onclick="nextImage()">Next &#8250;</button>
        </div>
        <div class="image-container">
            <img id="fullscreenImg" src="" alt="">
            <div class="image-info">
                <h2 id="fullscreenTitle"></h2>
                <p id="fullscreenDescription"></p>
            </div>
        </div>
    </div>

    <script src="gallery-1.js"></script>
</body>
</html>
