Im creating a page that utilzes forms. In the forms there are a number of combo/drop down boxes. I will be using the same lists in many forms so I wanted to create a function... well.. this is my first time trying this and I'm having a little trouble. Here is my code:
And the portion of the web page:
All I end up with is a blank select box w/no options. That says to me that Im not getting any data from the db..but I can't spot the problem. Any help would be great, thanks!
Code:
function listbldg ()
{
$dbconnect = mysql_connect($hostname,$username,$password) or die("Connetion to database failed!");
$dbname = "mis";
mysql_select_db($dbname,$dbconnect);
$bldgdata = mysql_query("select * from list_bldg");
while ($data1 = mysql_fetch_object($bldgdata))
{
echo"<option value=\"".$data1->bldg."\">".$data1->bldg."</option>\n";
}
}
And the portion of the web page:
Code:
<tr>
<td>Building</td>
<td>
<select name="bldg">
<?php listbldg() ?>
</select>
</td>
</tr>
All I end up with is a blank select box w/no options. That says to me that Im not getting any data from the db..but I can't spot the problem. Any help would be great, thanks!