$row['id'], "date" => formatDate($row['year'], $row['month'], $row['day']), "accountId" => $row['account_id'], "accountName" => $row['account_name'], "label" => $row['label'], "expense" => $row['expense'], "amount" => $row['amount'], "categoryId" => $row['category_id'], "comment" => $row['comment'] ); array_push($records, $record); } $data = array("recordCount" => count($records), "records" => $records); $jsonData = json_encode($data, JSON_PRETTY_PRINT); requestOk($jsonData); } } else if($action == "save-category") { $id = getMandatoryRequestValue("id"); $categoryId = getMandatoryRequestValue("categoryId"); $rowCount = dbUpdate("UPDATE record SET category_id = ? WHERE id = ?", $categoryId, $id); if($rowCount) { requestOk("Category set for $rowCount record"); } } else if($action == "save-comment") { $id = getMandatoryRequestValue("id"); $comment = getMandatoryRequestValue("comment"); $rowCount = dbUpdate("UPDATE record SET comment = ? WHERE id = ?", $comment, $id); if($rowCount) { requestOk("Comment saved for $rowCount record"); } } else { requestFail("Unknown request action \"$action\""); } closeDatabaseConnection(); ?>