try this code it works for me


$host="localhost"; // Host name
$username="root"; // Mysql username
$password=""; // Mysql password
$db_name="forum"; // Database name
$tbl_name="test_mysql"; // Table name

// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");

$sql="SELECT * FROM test_mysql";


<form name="form1" method="post" action="">
<select name="Names" id="Names">

while($rows=mysql_fetch_array($result, MYSQL_ASSOC))


echo"<option>". $rows['name']."</option>"; //to display names from database in field called name





nav33n commented: Thanks for the rep man. I am not good enough though. I m still learning. +1