我正尝试连接到MySQL并将数据填充到Dropdown。这是我的代码。某些原因下拉列表没有被填充。请建议。
这是代码。
$mysqli_connection = new mysqli($db_host, $db_username, $db_password, $db_database);
if (isset($_POST['Submit_1'])) {
require 'submit.php';
require 'validate.php';
if ($form_errors = validate_form()) {
show_form($form_errors);
}
else
{
form_submit_1();
}
}
else
{
show_form();
}
function show_form($errors = '')
{
// were there any errors?
if ($errors) {
//show errors
}
?>
$sql = "SELECT id, code FROM table1";
$result11 = $mysqli_connection->query($sql);
echo " ";
while ($row = $result11->fetch_assoc()) {
echo "$row[code]";
}
echo "";
?>
} // End of show_form()
?>