我試圖簡單地從表格中顯示兩個字段,例如名字,姓氏,將它們組合並顯示在可以選擇的下拉菜單中,並與用戶輸入的其他數據一起存儲。下面,爲一個領域工作,但我努力結合姓氏,我曾嘗試concat,但我認爲我做錯了。提前致謝。Concat兩個字段放入下拉菜單
//Drop Down Select
$sql = "SELECT concat (firstname, lastname) as username FROM users_tbl";
$result = pg_query($sql);
echo "<select name='firstname'>";
while ($row = pg_fetch_array($result)) {
echo "<option value='" . $row['firstname'] . "'>" . $row['firstname'] ."</option>";
}
echo "</select>";
// close connection
警告:pg_query()[function.pg-query]:查詢失敗:錯誤:列「lastname」不存在於第36行的/var/www/html/Test/rivers/RiverEnter.php中的字符27 – Tom
所需報價?第36行是$ sql行 – Tom
@Tom現在檢查。 –