Hello everyone, I am wanting to create a dropdown list box that is populated from a mysql database, currently I have figured how to query out what information I need from my database but I do not know how to get it to display correctly in the drop down box. Can someone give me some pointers or help? Down below is a sample code I have created which queries my database and shows the information I queried on the screen, can anyone give me some pointers or lead me in the right direction on making the listbox have the values? After I get that far, I may have other questions, because once someone clicks on one of the values from the dropdown list, I would like to run a query on the value selected and show values on the screen based on what is clicked.. Thank you guys for your time.
Example:
?>
$user="mysqluser";
$pass="****";
$db="test";
$link = @mysql_connect ( "localhost", $user, $pass );
if ( ! $link ) {
die ( "Couldn't Connect to Preferred Breeders Database. Try Again".mysql_error());
}
@mysql_select_db($db)
or die ( "Couldn't open $db: ".mysql_error() );
$result=mysql_query("SELECT DISTINCT NAME FROM test.states WHERE (STATE = 'MS')");
$num_rows=mysql_num_rows($result);
while ($a_row=mysql_fetch_row($result)){
print "\n";
foreach ($a_row as $field){
print "$field
";
}
print "\n";
}
mysql_close($link);
?>