$result = $db->getUserUpdates($sortType, $userId); } $response["message"] = "Query Successful"; } else { // user credentials are wrong $response['error'] = true; $response['message'] = 'One or more field(s) missing or invalid'; } echoResponse(200, $response); }); $app->get('/updatecomments', function () use($app) { $response = array(); $updateId = $app->request()->get('updateId'); $db = new DbHandler(); // fetching all user tasks $result = $db->getUpdateComments($updateId); $response["error"] = false; // $commentCount = $db->getCommentCount("update", $updateId); // echo $commentCount; // $response["commentCount"] = $commentCount["count"]; $response["comments"] = array(); // looping through result and preparing updates array while ($comment = $result->fetch_assoc()) { $tmp = array(); $tmp["commentId"] = $comment["id"]; $tmp["updateId"] = $comment["updateId"]; $tmp["commenterId"] = $comment["commenterId"]; $tmp["commenterName"] = $comment["commenterName"]; $tmp["commentText"] = $comment["commentText"]; $tmp["timeOfComment"] = $comment["timeOfComment"]; array_push($response["comments"], $tmp);