Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/55.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
组合firstname和lastname在php中将其显示为fullname_Php_Mysql - Fatal编程技术网

组合firstname和lastname在php中将其显示为fullname

组合firstname和lastname在php中将其显示为fullname,php,mysql,Php,Mysql,我创建了一个成功表单,查看用户的全名、用户名和密码 注册后表单上的密码,现在我的问题是如何将名字和姓氏合并为全名并显示在我的文本框中。你可以帮助我。谢谢 以下是我的成功表单代码示例: <form > <div class="form-group row" style="margin-top:60px;"> <!-- Material input --> <label for="username" class="

我创建了一个成功表单,查看用户的全名、用户名和密码 注册后表单上的密码,现在我的问题是如何将名字和姓氏合并为全名并显示在我的文本框中。你可以帮助我。谢谢

以下是我的成功表单代码示例:

<form >

     <div class="form-group row" style="margin-top:60px;">
        <!-- Material input -->
        <label for="username" class="col-sm-1 col-form-label"><strong>Name:</strong></label>
        <div class="col-sm-10">
            <div class="md-form mt-0">
                <input type="text" class="form-control" id="name" name="name" style="margin-left:55px; width:180px;" value="<?php echo $name?>" readonly="true">
            </div>
        </div>
    </div>
</form>

名称:

您将在
$row['name']
中找到name。另外,不要循环查看您的结果,只有一个结果$lastName=$fname.$lname。您必须连接字符串,因为您已经在查询中以“名称”形式连接,您只有一个输出:
$row['name']
谢谢大家的hep,对不起,我只是初学者
<?php 

include_once('connection.php');

$sql = "select concat(fname,'',lname) as name from visitor order by id DESC limit 1";
$result = mysqli_query($conn,$sql);
while ($row = mysqli_fetch_array($result)) {

          $fname=$row['fname'];
          $lname=$row['lname'];

}


?>