-2

I set up MySQL server and i'm trying to get data from SQL server using Arduino and Ethernet shield.Problem is i can't remove unusefull text from output.

I don't know much about php so i can't try much things.

    <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>

I expect the output of tryjson.php to be A1,but the actual output is [{"full_name":"A1"}].

aynber
  • 22,380
  • 8
  • 50
  • 63

1 Answers1

0

Is this what you wanted?

   <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 $row['full_name'];
        }
    ?>
    </body>
    </html>
bassxzero
  • 4,838
  • 22
  • 34