Example #1
0
function get_latest_new()
{
    include '../model/news.php';
    $news = new news();
    $row = $news->latest_news();
    if (!$news) {
        echo '{"result": 0, "message": "No news"}';
        return;
    }
    echo '{"result": 1, "news": [';
    while ($row) {
        echo json_encode($row);
        $row = $news->fetch();
        if ($row) {
            echo ",";
        }
    }
    echo "]}";
    return;
}