2 回答
TA贡献1816条经验 获得超6个赞
使用 Mysql 你可以试试这个 concat()
$query="select concat(firstname,' ',lastname) as fullname from user_details";
$exec = $conn->prepare($query);
$exec->execute();
$rc = $exec->rowCount();
$result=$exec->fetchAll();
<select class="un">
<option class="op" value="" disabled selected style="color:gray">Username</option>
<?php foreach ($result as $output) { ?>
<option class="op"> <?php echo $output["fullname"]; ?></option>
<?php } ?>
</select>
TA贡献1869条经验 获得超4个赞
更新此视图代码:
<select class="un">
<option class="op" value="" disabled selected style="color:gray">Username</option>
<?php foreach ($result as $output) { ?>
<option class="op"> <?php echo $output["firstname"] .' '.$output["lastname"]; ?></option>
<?php } ?>
</select>
- 2 回答
- 0 关注
- 125 浏览
添加回答
举报