prepare("select id, coord, color from pixel where id > :newerthan order by id"); $stmt->bindParam(":newerthan", $_GET["newerthan"]); $result = $stmt->execute(); if (!$result) pdo_die($stmt); $rows = $stmt->fetchAll(PDO::FETCH_ASSOC); echo json_encode($rows); } elseif (isset($_GET["coord"])) { add($_GET["coord"], $_GET["color"]); } function add($coord, $color) { $conn = getconn(); $stmt = $conn->prepare("insert into pixel(coord, color) values(:coord, :color)"); $stmt->bindParam(":coord", $coord); $stmt->bindParam(":color", $color); $result = $stmt->execute(); if (!$result) pdo_die($stmt); }