我最近学习了php,我是php的新手。 Json数据未显示。当我在托管服务器上运行此代码时显示数据,但在localhost数据中不显示
header('Content-type: application/json');
$newArray= array();
include("include/db_connection.php");
$sql="SELECT categories.n_id, n_title, n_desc, n_img_url, n_url from news INNER JOIN categories ON news.n_id=categories.n_id WHERE categories.c_name='Headlines' ORDER BY categories.n_id DESC LIMIT 3";
$res=mysqli_query($connection,$sql) or die("Query Problame ".mysqli_error());
if(mysqli_num_rows($res)>0){
while($row=mysqli_fetch_assoc($res)){
$newArray['articles'][]=$row;
}
}
echo json_encode($newArray);