//getting record by id $id = $_GET['id']; $item = ItemManager::GetById($id); echo json_encode($item); } else { //getting all records $items = ItemManager::GetAllItems(); echo json_encode($items); } break; case "PUT": $newRecordData = fopen("php://input", "r"); $data = stream_get_contents($newRecordData); fclose($newRecordData); parse_str($data); $newId = ItemManager::AddNewItem($desc, $price, $quantity); echo "The item {$desc} has been inserted with the id {$newId}."; break; case "POST": $id = $_POST["id"]; if (isset($id) && $id != 0 && !empty($id)) { $desc = $_POST["desc"]; $price = $_POST["price"]; $quantity = $_POST["quantity"]; $rows = ItemManager::UpdateItem($id, $desc, $price, $quantity); echo "Rows updated: {$rows}."; } else { echo "Please enter a valid item id to update."; } break; case "DELETE":