function getTableBody($tid, $datesCoordination) { $tableBody = ''; if (isset($tid) == false && isset($datesCoordination) == false) { $tableBody .= '<tr><td><input type="datetime-local" class="form-control" oninput="addNewLine()"/></td>'; $tableBody .= '<td>'; $tableBody .= '<select class="form-control" required>-'; $tableBody .= '<option value="0">Ja</option>'; $tableBody .= '<option value="1">Nein</option>'; $tableBody .= '<option value="2">Vielleicht</option>'; $tableBody .= '</select>'; $tableBody .= '</td>'; $tableBody .= '<td>'; $tableBody .= '</td>'; $tableBody .= '</tr>'; return $tableBody; } $dbc = new DBConnect(); $userVotes = $dbc->loadUsersVotes_db($tid, $_SESSION['userid']); if (count($userVotes) > 0) { foreach ($userVotes as $vote) { $v = $vote->getVote(); $tableBody .= '<tr><td><input type="datetime-local" class="form-control" readonly value="' . date_format($vote->getDate(), "Y-m-d\\TH:i") . '"/></td>'; $tableBody .= '<td>'; $tableBody .= '<select class="form-control" required>-'; $tableBody .= '<option value="0" ' . ($v == 'Ja' ? 'selected' : '') . '>Ja</option>'; $tableBody .= '<option value="1" ' . ($v == 'Nein' ? 'selected' : '') . '>Nein</option>'; $tableBody .= '<option value="2" ' . ($v == 'Vielleicht' ? 'selected' : '') . '>Vielleicht</option>'; $tableBody .= '</select>'; $tableBody .= '</td>'; $tableBody .= '<td>'; $tableBody .= '</td>'; $tableBody .= '</tr>'; } } else { if (isset($datesCoordination)) { $dateVotes = $datesCoordination->getResults(); foreach ($dateVotes as $vote) { $tableBody .= '<tr><td><input type="datetime-local" class="form-control" readonly value="' . date_format($vote->getDate(), "Y-m-d\\TH:i") . '"/></td>'; $tableBody .= '<td>'; $tableBody .= '<select class="form-control" required>-'; $tableBody .= '<option value="0">Ja</option>'; $tableBody .= '<option value="1">Nein</option>'; $tableBody .= '<option value="2">Vielleicht</option>'; $tableBody .= '</select>'; $tableBody .= '</td>'; $tableBody .= '<td>'; $tableBody .= '</td>'; $tableBody .= '</tr>'; } } } return $tableBody; }