示例#1
0
function viewAllCourses()
{
    include "models/course.php";
    $obj = new course();
    if (!$obj->viewAllCourses()) {
        echo '{"result": 0, "message": "You have no course in the database"}';
        return;
    }
    $row = $obj->fetch();
    echo '{"result": 1, "message": [';
    while ($row) {
        echo json_encode($row);
        $row = $obj->fetch();
        if ($row) {
            echo ',';
        }
    }
    echo "]}";
    return;
}