我设置了MySQL服务器,并试图使用Arduino和Ethernet shield从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"}]
。
答案 0 :(得分:0)
这是您想要的吗?
<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>