我已经了解了基本的Concat与sql的想法,但我无法在我的下拉菜单中获得第一个和姓氏之间的空格。代码都只是一个基本的东西我找不到给我一个名字和姓氏之间的空格。
<option value="" >Valuer of this Property</option>
<?php
$res=mysqli_query($conn, "SELECT CONCAT(first,surname) from listalot_users");
while($row=mysqli_fetch_array($res))
{
?>
<option><?php echo $row['CONCAT(first,surname)']; ?></option>
<?php
}
?>
</select>
答案 0 :(得分:1)
<option value="" >Valuer of this Property</option>
<?php
$res=mysqli_query($conn, "SELECT CONCAT(first,' ',surname) as full_name from listalot_users");
while($row=mysqli_fetch_array($res))
{
?>
<option><?php echo $row['full_name']; ?></option>
<?php
}
?>
</select>
答案 1 :(得分:0)
更新您的代码:
<option value="" >Valuer of this Property</option>
<?php
$res=mysqli_query($conn, "SELECT CONCAT(first, ' ', surname) as fullname from listalot_users");
while($row=mysqli_fetch_array($res))
{
?>
<option><?php echo $row['fullname']; ?></option>
<?php
}
?>
</select>