<div class="page-container" data-bind="if: currentView() === 'high-scores'"> <div class="well"> <h2>High Scores</h2> <table class="table table-border"> <thead> <tr> <th></th> <th>Level</th> <th>Score</th> <th>Date</th> </tr> </thead> <tbody> <?php $data_access = new DataAccess(); $highscores_array = $data_access->get_highscores(); foreach ($highscores_array as $row) { $date = date_create($row['end']); $dateScore = date_format($date, 'l, F jS, Y \\a\\t g:ia'); echo '<tr>'; echo '<td><img src="pics/Robot_Character1_Blue.png" height="60"/></td>'; echo '<td>' . $row['level_id'] . '</td>'; echo '<td>' . $row['highscore'] . '</td>'; echo '<td>' . $dateScore . '</td>'; echo '</tr>'; } ?> </tbody> </table> </div> </div>
<?php if ($_SERVER["REQUEST_METHOD"] !== 'GET') { http_response_code(405); exit; } require_once 'includes/data_access.php'; $data_access = new DataAccess(); $scores = $data_access->get_highscores(); header('Content-Type: application/json'); echo json_encode($scores);