[英]mySQL to JSON Object only returns first row
these lines of code : 这些代码行:
$sql ="SELECT * FROM parcours";
$r = mysqli_query($con,$sql);
$result = array();
while($res = mysqli_fetch_array($r)){
$result[] = $res;
}
echo json_encode(array("result"=>$result));
returns me only the first row of my DB request. 仅向我返回数据库请求的第一行。
How can I get all of it ? 如何获得所有这些?
I think you need to use mysqli_fetch_assoc
: 我认为您需要使用mysqli_fetch_assoc
:
while($res = mysqli_fetch_assoc($r)){
$result[] = $res;
}
and then : 接着 :
echo json_encode(array($result));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.