sql >> Database teknologi >  >> RDS >> Mysql

udfyld en valgboks med php mysql

Prøv dette:

<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>

Brug ikke mysql og mysqli sammen....du skal bruge mysqli eller PDO, men ikke en blanding af begge;)PS:Redigeret;)

Saludos.



  1. Tilslutning af MySQL til Visual Studio C#

  2. MariaDB POWER() Forklaret

  3. Viser MySQL-forespørgselsresultater fra Servlet til JSP

  4. Heroku - dump og indlæs enkelt tabel til delt postgres-database