"OK", 'Records' => $rows ]; print json_encode($ftableResult); } // Creating a new record (createAction) else if($_GET["action"] == "create") // the GET param comes from the createAction value in the FTable definition { // Insert record into database // by default FTable submits all relevant info via POST (see ajaxSettings) $result = mysqli_query("INSERT INTO people(Name, Age, RecordDate) VALUES('" . $_POST["Name"] . "', " . $_POST["Age"] . ",now());"); // Get last inserted record (to return to FTable) $result = mysqli_query("SELECT * FROM people WHERE PersonId = LAST_INSERT_ID();"); $row = mysqli_fetch_array($result); // Return result to FTable $ftableResult = [ 'Result' => "OK", 'Record' => $row ]; print json_encode($ftableResult); } // Updating a record (updateAction) else if ($_GET["action"] == "update") // the GET param comes from the updateAction value in the FTable definition { // Update record in database // by default FTable submits all relevant info via POST (see ajaxSettings) $result = mysqli_query("UPDATE people SET Name = '" . $_POST["Name"] . "', Age = " . $_POST["Age"] . " WHERE PersonId = " . $_POST["PersonId"] . ";"); // Return result to FTable $ftableResult = [ 'Result' => "OK" ]; print json_encode($ftableResult); } // Deleting a record (deleteAction) else if ($_GET["action"] == "delete") // the GET param comes from the deleteAction value in the FTable definition { // Delete from database // by default FTable submits all relevant info via POST (see ajaxSettings) $result = mysqli_query("DELETE FROM people WHERE PersonId = " . $_POST["PersonId"] . ";"); // Return result to FTable $ftableResult = [ 'Result' => "OK" ]; print json_encode($ftableResult); } // Close database connection mysqli_close($con); } catch(Exception $ex) { // Return error message $ftableResult = [ 'Result' => "ERROR", 'Message' => $ex->getMessage(), ]; print json_encode($ftableResult); } ?>