嗨,我有一些問題使用MYSQLI填充下拉框。 我到目前爲止的代碼是:使用MYSQLI來填充下拉框 - PHP
<?php
session_start();
if (!isset($_SESSION['myusername'])){
header("location:index.php");
}
include_once './includes/checkperm.php';
$permlevel = check_perm($_SESSION['myusername']);
if ($permlevel < "90") {
header("location:permtolow.php");
exit;
}
require_once($_SERVER['DOCUMENT_ROOT'].'/../dbcon.php');
?>
<div class="label">Select Name:</div>
<select name="names">
<option value = "">---Select---</option>
<?php
$queryusers = "SELECT username FROM finance";
$query = mysqli_query($con, $queryusers);
while ($d=mysqli_fetch_array($query)) {
echo "<option value='{".$d['username']."}'>".$d['username']."</option>";
}
echo '</select>'
?>
不幸的是下拉框保持爲空。 我可能錯過了一些簡單的東西。
'回聲 「<選項值='{」 $ d。[ '用戶名'。「}」>「;'這裏的值將看起來像'{Hampkade}'(添加'{} '在它周圍)。但你實際上並沒有輸出任何東西,應該是''之間的東西 - 如果這不能回答你要找的東西,你需要啓用錯誤報告'error_reporting(E_ALL);' ini_set('display_errors',1);' – Qirel
不是但是。檢查http://www.w3schools.com/tags/tryit.asp?filename=tryhtml_option –