BrandonSi
06-20-2006, 09:38 PM
I'm trying to get a simple php script to populate a dropdown box.. the php code works as a standalone .php, but when I add it to the HTML file with some other forms and view the page, it fails.. So the code is solid, I think it must be a problem with the echo statements?! I don't even get the dropdown box! Any suggestions?
<form action="handle.php" action="POST">
<input type="text" name="amount">amount
<input type="text" name="category">category
<input type="text" name="description">description
<?
$dbh=mysql_connect ("localhost", "branthan_et", "password") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("branthan_expensetracker");
$sqlOptions = "SELECT * from categories";
$resultOptions = mysql_query($sqlOptions);
echo '<select name="selectName">';
echo '<option value="">--Select--</option>';
while($opt = mysql_fetch_array($resultOptions))
{
echo '<option value="'.$opt['categories'].'">'.$opt['categories'].'</option>';
}
echo '</select>';
?>
<input type="text" name="payment">payment
<input type="text" name="amount">amount
<input type="text" name="date">date
</form>
<form action="handle.php" action="POST">
<input type="text" name="amount">amount
<input type="text" name="category">category
<input type="text" name="description">description
<?
$dbh=mysql_connect ("localhost", "branthan_et", "password") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("branthan_expensetracker");
$sqlOptions = "SELECT * from categories";
$resultOptions = mysql_query($sqlOptions);
echo '<select name="selectName">';
echo '<option value="">--Select--</option>';
while($opt = mysql_fetch_array($resultOptions))
{
echo '<option value="'.$opt['categories'].'">'.$opt['categories'].'</option>';
}
echo '</select>';
?>
<input type="text" name="payment">payment
<input type="text" name="amount">amount
<input type="text" name="date">date
</form>