我试图简单地显示表中的两个字段,例如名字、姓氏,将它们组合并显示在可以选择的下拉菜单中,并与用户输入的其他数据一起存储。下面,适用于一个领域,但我正在努力组合姓氏,我尝试过 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