我怎么能从数据库的评论得到新闻列表


How can i get list of news from database with comments

我要为android做一个新闻应用。我将json_encode写入PHP文件。但我只是想在while中添加注释。我到处都找遍了,就是找不到。你能帮帮我吗?

这是我的php代码
if (!empty($result)) {
        // check for empty result
        if ($result->num_rows > 0) {
            $response["success"] = true;
            $response["news"] = array();
            while($row = $result->fetch_object()){
            $news = array();
            $news["id"] = $row->id;
            $news["title"] = $row->title;
            $news["details"] = $row->short;
            $news["thumbURL"] = $thumb.$row->images;
            $news["LargeImageURL"] = $big.$row->images;
            array_push($response["news"], $news);
            }
            // echoing JSON response
            echo json_encode($response);
        } else {
            // no news found
            $response["success"] = false;
            $response["message"] = "No news found";
            // echo no users JSON
            echo json_encode($response);
        }
    } else {
        // no news found
        $response["success"] = false;
        $response["message"] = "No news found";
        // echo no users JSON
        echo json_encode($response);
    }

,我想添加item的注释,比如在photo

https://i.stack.imgur.com/RnaOJ.jpg

我发现它的工作很好。谢谢你的帮助。

if (!empty($result)) {
        // check for empty result
        if ($result->num_rows > 0) {
            $response["success"] = true;
            $response["news"] = array();
            while($row = $result->fetch_object()){
            $commentsql = $db->query("SELECT * FROM comment where cid='".$row->id."' order by id desc limit 0,10");
            $comments = array();
            while($comm = $commentsql->fetch_object()){
            $comments[] = array(
                'id'    => $comm->id,
                'text'  => $comm->comment
                );
            }
            $news = array();
            $news["id"] = $row->id;
            $news["title"] = $row->title;
            $news["details"] = $row->short;
            $news["thumbURL"] = $thumb.$row->images;
            $news["LargeImageURL"] = $big.$row->images;
            $news["comment"] = $comments;
            array_push($response["news"], $news);
            }
            // echoing JSON response
            echo json_encode($response);
        } else {
            // no news found
            $response["success"] = false;
            $response["message"] = "No news found";
            // echo no users JSON
            echo json_encode($response);
        }
    } else {
        // no news found
        $response["success"] = false;
        $response["message"] = "No news found";
        // echo no users JSON
        echo json_encode($response);
    }