如何使用php仅显示全名

我设置了 MySQL 服务器,我正在尝试使用 Arduino 和以太网屏蔽从 SQL 服务器获取数据。问题是我无法从输出中删除无用的全文。


我不太了解 php,所以我不能尝试很多东西。


    <html>

    <head>

    <title>Try Session JSON</title>

    </head>

    <body>

    <?php


        $dbusername = "root";  

        $dbpassword = ""; 

        $server = "localhost"; 

        $dbconnect = mysqli_connect($server, $dbusername, $dbpassword);

        $dbselect = mysqli_select_db($dbconnect, "test");

        $sql="SELECT full_name FROM test.eattandance WHERE id=1";

        $records=mysqli_query($dbconnect,$sql);

        $json_array=array();

        while($row=mysqli_fetch_assoc($records))

    {

        $json_array[]=$row;

    }

        /*echo '<pre>';

        print_r($json_array);

        echo '</pre>';*/

    echo json_encode($json_array);

    ?>

    </body>

    </html>

我希望 tryjson.php 的输出为 A1,但实际输出为[{"full_name":"A1"}].


HUX布斯
浏览 118回答 1
1回答

慕桂英3389331

这是你想要的吗?&nbsp; &nbsp;<html>&nbsp; &nbsp; <head>&nbsp; &nbsp; <title>Try Session JSON</title>&nbsp; &nbsp; </head>&nbsp; &nbsp; <body>&nbsp; &nbsp; <?php&nbsp; &nbsp; &nbsp; &nbsp; $dbusername = "root";&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; $dbpassword = "";&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; $server = "localhost";&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; $dbconnect = mysqli_connect($server, $dbusername, $dbpassword);&nbsp; &nbsp; &nbsp; &nbsp; $dbselect = mysqli_select_db($dbconnect, "test");&nbsp; &nbsp; &nbsp; &nbsp; $sql="SELECT full_name FROM test.eattandance WHERE id=1";&nbsp; &nbsp; &nbsp; &nbsp; $records=mysqli_query($dbconnect,$sql);&nbsp; &nbsp; &nbsp; &nbsp; $json_array=array();&nbsp; &nbsp; &nbsp; &nbsp; while($row=mysqli_fetch_assoc($records))&nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $json_array[]=$row;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; echo $row['full_name'];&nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; ?>&nbsp; &nbsp; </body>&nbsp; &nbsp; </html>
打开App,查看更多内容
随时随地看视频慕课网APP