$return = array('result' => Request::getRequest($id)['state']); echo json_encode($return); return; } ?> <!doctype html> <html> <head> <link rel="stylesheet" href="css/requests/style.css"> <script src="libs/jquery.js"></script> <script src="js/requests.js"></script> </head> <body> <table> <?php foreach (Request::getAllRequests()['unsorted'] as $req) { $class = 'unsorted'; if ($req['state'] == 0) { $class = 'declined'; } else { if ($req['state'] == 1) { $class = 'accepted'; } } $id = $req['id']; echo "<tr id='req-{$id}' class='row {$class}'>"; foreach ($req as $key => $value) { echo "<td class='{$key}'>{$value}</td>"; } echo "<td><button onclick='button({$id}, 1)'>Accept</button></td>"; echo "<td><button onclick='button({$id}, 0)'>Decline</button></td>";
<?php // we now in presentation layer // we will include business layer to load business logic include 'model/request.php'; // init Contact Model from Business Logic $contact = new Request(); // insert new Contact if post data exists if (isset($_POST["email"]) && $_POST["text"]) { $contact->createRequest($_POST["email"], $_POST["subject"], $_POST["text"]); } // now load all Movies $data = $contact->getAllRequests(); // prepare HTML Table function getHTMLTable($tabledata) { $html = '<br />'; $html .= '<h1>Liste der bereits erstellten Anfragen:</h1>'; $html .= '<table id="moviestable">'; $html .= '<thead><tr>'; $html .= '<th>Email</th>'; $html .= '<th>Subject</th>'; $html .= '<th>Text</th>'; $html .= '</tr></thead>'; foreach ($tabledata as $contact) { $html .= '<tbody><tr>'; $html .= '<td>' . $contact['email'] . '</td>'; $html .= '<td>' . $contact['subject'] . '</td>'; $html .= '<td>' . $contact['text'] . '</td>'; $html .= '</tr></tbody>'; }