<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="">
<meta name="author" content="">
<link rel="icon" href="favicon.ico">
<title>Llenar select HTML con MySQL PHP: Ejemplos - BaulPHP</title>

<link href="css/bootstrap/bootstrap.min.css" rel="stylesheet">

<link href="assets/sticky-footer-navbar.css" rel="stylesheet">
</head>

<body>
<header> 

</header>


<div class="container">
<h3 class="mt-5"><a href="" target="_blank">Llenar select HTML con MySQL PHP</a></h3>
<hr>
<div class="row">
<div class="col-12 col-md-12"> 


<?php
$usuario = 'Freddy';
$contrasena = '2022';
$db = new PDO('mysql:host=localhost;dbname=admsyste_portal', $usuario, $contrasena);
?>
<div align="left">
<p>Seleccione un pais del siguiente menú:</p>
<form class="form-inline">
<div class="form-group mb-2">
<label for="staticEmail2">Paises:</label>
</div>
<div class="form-group mx-sm-3 mb-2">
    <label for="paises" class="sr-only">Paises:</label>
    <select class="form-control" >
        <option value="">Seleccione:</option>
            <?php
            $query = $db->prepare("SELECT * FROM paises");
            $query->execute();
            $data = $query->fetchAll();

            foreach ($data as $valores):
            echo '<option value="'.$valores["id"].'">'.$valores["paises"].'</option>';
            endforeach;
            ?>
</select>
</div>
<button class="btn btn-primary mb-2">Enviar</button>
</form>
</div>

</div>
</div>


</div>

<footer class="footer">
<div class="container"> <span class="text-muted">
<p>Códigos <a href="" target="_blank">BaulPHP</a></p>
</span> </div>
</footer>
<script src="assets/jquery-1.12.4-jquery.min.js"></script>

<script src="dist/js/bootstrap.min.js"></script>
</body>
</html>