<!-- Responsible for dealing with business.php (Business Layer) but NOT with database itself --> <?php // PRESENTATION LAYER include "business/business.php"; // get business logic $alcohol = new Alcohol(); // get alcohol model // INSERT if post-parameter is set if (isset($_POST["alcoholname"]) && $_POST["alcoholname"]) { // call business layer $alcohol->createAlcohol($_POST["alcoholname"], $_POST["level"]); } // UPDATE if post-parameter is set if (isset($_POST["updateName"]) && $_POST["updateLevel"]) { // call business layer $alcohol->updateAlcohol($_GET['id'], $_POST["updateName"], $_POST["updateLevel"]); } // READ ALL -> call business layer $data = $alcohol->getAllAlcohol(); // prepare HTML Table (use .= for appending) function getHTMLTable($alcoholData) { $html = null; // if there are types of alcohol (alcoholData) available if ($alcoholData != null) { $html = '<table id="alcoholtable">'; $html .= '<thead><tr>'; $html .= '<th>Type of Alcohol</th>'; $html .= '<th>Description</th>'; $html .= '<th>Image</th>';
<!-- Responsible for the delete-site for deleting existing types of alcohol --> <!-- No html-formatting because user doesn't see this site because it switches back to index.php very fast --> <?php include "business/business.php"; // get business logic // check if there is a get parameter in the url if (!empty($_GET['id'])) { // set the variable alcoholname with the id of the url $alcoholname = $_REQUEST['id']; // instance a new alcohol $alcohol = new Alcohol(); // delete the alcohol via the name which is unique $alcohol->deleteAlcohol($alcoholname); } // go back to index.php header("Location: index.php");