|
I have PHP file that creates a List Box and populates it from a field in a MySQL database table. I need to place the PHP code for the List Box into an HTML file to do the same. I've been trying to figure this out for hours scouring the web. I must be missing something simple. I tried making the PHP code a function. The function worked, but when I included it and called it from the HTML file, nothing was displayed. Thanks in advance.
The codes follow.
This is the PHP code that works:
<?php
$dbc = mysql_connect('xxxxx', 'yyyyy',zzzzz')
or die('Error connecting to MySQL server.');
mysql_select_db('mydb');
$result = mysql_query("select distinct assn from compsin order by assn");
echo '<select name="compsin">';
while ($nt= mysql_fetch_assoc($result)) {
echo '<option value="' . $nt['id'] . '">' . $nt['assn'] . '</option>';
}
echo '</select>';
?>
==================================================
Here is the HTML code without PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>List Box PHP in HTML</title>
</head>
<body>
<form method="post" action="1004mcout.php">
<p><center>List Box PHP in HTML</CENTER></P>
<p>-- FOR CONDOS ONLY -- If the subject is a condo, enter the name of the subject condo association (as it appears on the comparables spreadsheet). If the subject is not a condo, leave blank.</p>
<p></p>
<p>Click "SUBMIT" to display the calculation results</p>
<input type="submit" name="Submit" value="Submit" />
<br />
</form>
</body>
</html>
|