<?php
$servername = "localhost";
$username = "itladevprubycom_enma";
$password = "53gNpj4t.xDc";
$database = "itladevprubycom_enma1";

$conexion = new mysqli($servername, $username, $password, $database);

if ($conexion->connect_error) {
    die("Error de conexión: " . $conexion->connect_error);
}

$query = $conexion->prepare("SELECT * FROM Usuarios");
$query->execute();
$result = $query->get_result();

if ($result->num_rows == 0) {
    echo "No hay datos en la base de datos.";
} else {
    $datos = [];
    while ($row = $result->fetch_assoc()) {
        $datos[] = $row; 
    }
}

?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <!-- Incluir estilos y scripts de UIkit -->
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/uikit@3.18.1/dist/css/uikit.min.css" />
    <script src="https://cdn.jsdelivr.net/npm/uikit@3.18.1/dist/js/uikit.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/uikit@3.18.1/dist/js/uikit-icons.min.js"></script>
</head>
<body>
    <div class="uk-section">
        <div class="uk-container">
            <div class="uk-grid uk-child-witdh-1-2">
                <h2>Usuarios:</h2>
                <?php foreach($datos as $value){?>
                    <div class="uk-card uk-card-body">
                        <?php echo $value["nombre"];?>
                    </div>
                <?php } ?>
            </div>
            <a href="index.php" class="uk-button uk-button-default">Volver al inicio</a>
        </div> 
    </div>
    
</body>
</html>

