<?php
// require("LO DE LA BASE DE DATOS");

// hacer la consulta
$sql = "SELECT * FROM cliente";
$result = $conn->query($sql);

?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Pruebas</title>
    <!-- las direcciones de la api para lo la exportacion al excel -->
    <script src="https://unpkg.com/xlsx@0.16.9/dist/xlsx.full.min.js"></script>
    <script src="https://unpkg.com/file-saverjs@latest/FileSaver.min.js"></script>
    <script src="https://unpkg.com/tableexport@latest/dist/js/tableexport.min.js"></script>


    <link rel="stylesheet" href="cs-excel.css">
</head>
<body>

    <div >
        <button id="btnExportar">
            <i>exportar datos a excel</i>
        </button>

        <table id="tabla">
            <thead>
                <tr>
                    <th>ID</th>
                    <th>Nombres</th>
                    <th>Apellidos</th>
                    <th>Identificacion</th>
                    <th>Fecha</th>
                </tr>
            </thead>

            <tbody>
                <?php
                while($row = $result->fetch_assoc()){
                    echo "<tr>";
                    echo "<td>" . $row["id"] . "</td>";
                    echo "<td>" . $row["nombres"] . "</td>";
                    echo "<td>" . $row["apellidos"] . "</td>";
                    echo "<td>" . $row["nidentificacion"] . "</td>";
                    echo "<td>" . $row["fecha"] . "</td>";
                    echo "</tr>";

                }
                ?>

            </tbody>

        </table>

    </div>
    
 <script type="module" src="js-excel.js"></script>

</body>
</html>