<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>

    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet"
        integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
    <style>
    /* CSS to hide the button when printing */
    @media print {
        .print-button {
            display: none;
        }
    }
    </style>
</head>

<body>
    <div class="container">
        <div class="row">
            <!-- <div class="col-lg-"></div> -->
            <div class="col-lg-12">
                <?php
    // Connect to the database
    $conn = mysqli_connect("localhost", "root", "", "workstatus");
    if (!$conn) {
        die("Error: Unable to connect to the database. " . mysqli_connect_error());
    }

    // Retrieve data from the "create_proforma" table
    $query = "SELECT * FROM create_proforma";
    $result = mysqli_query($conn, $query);

    // Check if there are any records in the table
    if (mysqli_num_rows($result) > 0) {
        ?>
                <table class="table table table-responsive table table-bordered table-dark text-white text-center">
                    <tr>
                        <th>Name</th>
                        <th>Email</th>
                        <th>Number</th>
                        <th>Profile</th>
                        <th>Experience</th>
                        <th>Image</th>
                    </tr>
                    <?php
            // Loop through the records and display them in the table
            while ($row = mysqli_fetch_assoc($result)) {
                ?>
                    <tr>
                        <td><?php echo $row['name']; ?></td>
                        <td><?php echo $row['email']; ?></td>
                        <td><?php echo $row['number']; ?></td>
                        <td><?php echo $row['profile']; ?></td>
                        <td><?php echo $row['experience']; ?></td>
                        <td><img src="<?php echo $row['image']; ?>" alt="Image" width="100"></td>
                    </tr>
                    <?php
            }
            ?>
                </table>
                <?php
    } else {
        echo "No proforma details found.";
    }

    // Close the database connection
    mysqli_close($conn);
    ?>

                <button class="print-button btn btn-danger" onclick="printTable()">Print</button>

                <!-- Add JavaScript function to print the table -->
                <script>
                function printTable() {
                    window.print();
                }
                </script>
            </div>
            <!-- <div class="col-lg-2"></div> -->
        </div>
    </div>

</body>

</html>