<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Bootstrap Info Boxes</title>
    <!-- Bootstrap CSS CDN -->
    <link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet">
</head>

<body>

<div class="container-fluid">
    <div class="row justify-content-center" style='margin:0px;'> 
        <h1 style="margin:10px 0px 15px 10px;font-size:30px;text-align:center">Dashboard</h1>
        <!-- PHP loop to generate cards dynamically -->
        <?php
        include "../database/database.php";
        // Fetch all image data from the database
        $sql = "SELECT id, image FROM imv_product";
        $result = $connection->query($sql);

        if ($result->num_rows > 0) {
            while ($row = $result->fetch_assoc()) {
                $imageData = $row['image'];
                $id = $row['id'];
                echo '
                <div class="col-sm-4" style="border-radius:10px; width:320px; height:150px; margin:10px">
                    <div class="card mb-3">
                        <div class="card-header bg-info text-white">
                            <h5 class="card-title">Info Box Title ' . $id . '</h5>
                        </div>
                        <div class="card-body">
                            <div class="text-center">
                                <img src="data:image/jpeg;base64,' . base64_encode($imageData) . '" class="img-fluid mb-3" alt="Sample Image" style="margin-left:auto;margin-right:auto;">
                            </div>
                            <h5 class="card-title">Info Box Content</h5>
                            <p class="card-text">This is an example of an info box with an image. You can add more content here as needed.</p>
                            <a href="#" class="btn btn-primary">Learn More</a>
                        </div>
                    </div>
                </div>';
            }
        } else {
            echo '<div class="col-12"><p class="text-center">No images found.</p></div>';
        }
        ?>
    </div>
</div>

<!-- jQuery and Bootstrap JS CDN -->
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.5.4/dist/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>

</body>
</html>
