PHP combobox mysql

0

How can I get to fill a combobox in html with mysql data? I have this done but it does not work.

    <?php
//Creando conexion
$conexion=mysqli_connect("localhost","root","") or die("Problemas en la conexion");
//seleccionando base
mysqli_select_db("ejercicio13",$conexion) or die("Problemas en la selección de la base de datos");
mysqli_query ("SET NAMES 'utf8'");
//seleccionando datos de la base de datos 

$datos=mysql_query("select * from pelicula",$conexion) or
die("Problema seleccionando datos:".mysqli_error());
?>
<!DOCTYPE HTML>
<html lang="en-US">
<head>
 <meta charset="UTF-8">
 <title></title>
 <style type="text/css" src="ejemplosappletenhtml.css"></style>
</head>
<body>
        <h1>appletenhtml</h1>
  <h2>Ejemplo de select / combobox en php</h2>
    <hr>
    <?php if ($datos) {   ?>
         <!-- Creando el select-->
         <select name="select" id="select">
   <!-- Llenando las opciones del select-->
           <?php  while ($registro=mysqli_fetch_assoc($datos)) {?>
              <option value="<?php echo $registro['id'];?>"><?php echo $registro['nivel']; ?></option>
           <?php }?>
         </select>
    <?php   } else{?>
         <p>No hay contactos en la agenda</p>
    <?php } ?>
<hr><footer><h1>appletenhtml</h1></footer></body></html>
    
asked by 22.01.2018 в 20:06
source

0 answers