Quantcast
Channel: PHP Freaks: PHP Help
Viewing all articles
Browse latest Browse all 13200

Pupulate dropdown form MySql

$
0
0
I am stuck. I am trying to populate a dropdown box in my form from MySql database. Connection to db is working but I can't seem to be able to get the dropdown box on my form to populate...all I see is Please Select with an empty clickable row below. Help!? Thanks.


$items = "|Please Select[c]\n";

$host="localhost"; // Host name
$username="xxxxxxxxxx"; // Mysql username
$password="xxxxxxxx"; // Mysql password
$db_name="test_db"; // Database name
$tbl_name="test_table"; // Table name

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

if(! $conn){ die('Could not connect: ' . mysql_error());}echo "Connected successfully\n";

$result = mysql_query("SELECT * FROM test_table" ) or die(mysql_error());

foreach ($result as $r)
$items .= $r->id . '|' . $r->corpprice . "\n";
return $items;

Viewing all articles
Browse latest Browse all 13200

Trending Articles