I need help regarding my PHP drop down list. I've created a Database call state. I'm trying to populate a state drop down on an html page using php connecting to mysql. Here is my code for the html page:
<form action="CreateUser.php" method="POST">
<label type='text'>State:</label>
<select name='state'>
<option value='0'>--Choose a State--</option>
<?php
$dbTable='states'
$QueryResult=msql_query('Select * from "$dbTable"');
while($Row = mysql_fetch_assoc($QueryResult))
{
?>
<option value="<?php echo $Row['StateID']; ?>">
<?php echo {$Row['StateName']}; ?>
</option>
<?php } ?>
</select>
<input id='movebutton' type = "Submit" name="submit" value="submit"/>
</form>
And here is my PHP code for the dbconnection:
$DBName = "business";
$DBConnect = @mysql_connect("localhost", "root", "");
if($DBConnect === FALSE)
{
echo "<p>Unable to connect to the database server.</p>" . "<p>Error code " . mysql_errno() . ": " . mysql_error() . "</p>";
}
else
{
$DB = mysql_select_db($DBName, $DBConnect);
if(!$DB)
{
echo "<p>Unable to connect to the database server.</p>" . "<p>Error code " . mysql_errno() . ": " . mysql_error() . "</p>";
mysql_close($DBConnect);
$DBConnect = FALSE;
}
}
Can someone tell me what I'm doing wrong? I've checked on this forum and also on YouTube regarding PHP dropdown. I'm new to php and still learning.