sql >> Base de Datos >  >> RDS >> Mysql

llenar un cuadro de selección con php mysql

Prueba esto:

<html><head><title>Connect to Database</title></head><body>
 <font size="4">Query gets Forename of nurse</font>
 <br><br><font size="4">Choose a name</font><br><br> 

 <form action="insert.php" method="post">
<select name="valuelist">;
<?php
$value=$_POST ["valuelist"];
$con = mysql_connect("localhost","root","") or die('Could not connect:'.mysql_error());
mysql_select_db("a&e", $con) or die('Could not select database.');

$fetch_nurse_name = mysql_query("SELECT DISTINCT Forename FROM nurse");


while($throw_nurse_name = mysql_fetch_array($fetch_nurse_name)) {
echo '<option   value=\"'.$throw_nurse_name[0].'">'.$throw_nurse_name[0].'</option>';
}
echo "</select>";


?>
<input type="submit" value="Submit">
</form></body></html>

No use mysql y mysqli juntos... debe usar mysqli o PDO, pero no una combinación de ambos;) PD:Editado;)

Saludos.