table
This commit is contained in:
parent
59095e1770
commit
ae973621e9
1 changed files with 42 additions and 36 deletions
|
|
@ -37,47 +37,53 @@ $lastMatches = array_slice($allMatches, 0, 8);
|
|||
<section>
|
||||
<h2>Latest Matches</h2>
|
||||
|
||||
<table border='1' class='sortable'>
|
||||
<thead>
|
||||
<tr>
|
||||
<!-- <th>Match Date</th> -->
|
||||
<tr><th>Player Name</th><th>Kills</th><th>Damage Dealt</th><th>Time Survived</th><th>Rank</th></tr>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
// Check if a match ID is provided in the GET request
|
||||
if (isset($_GET['matchid'])) {
|
||||
$matchId = $_GET['matchid'];
|
||||
$filename = "data/matches/" . $matchId . ".json";
|
||||
<table class='sortable'>
|
||||
|
||||
// Check if the JSON file for the given match ID exists
|
||||
if (file_exists($filename)) {
|
||||
// Read and decode the JSON file
|
||||
$jsonData = json_decode(file_get_contents($filename), true);
|
||||
|
||||
foreach ($jsonData['included'] as $includedItem) {
|
||||
if ($includedItem['type'] == "participant") {
|
||||
$playerStats = $includedItem['attributes']['stats'];
|
||||
echo "<tr>";
|
||||
echo "<td>" . htmlspecialchars($playerStats['name']) . "</td>";
|
||||
echo "<td>" . htmlspecialchars($playerStats['kills']) . "</td>";
|
||||
echo "<td>" . htmlspecialchars($playerStats['damageDealt']) . "</td>";
|
||||
echo "<td>" . htmlspecialchars($playerStats['timeSurvived']) . "</td>";
|
||||
echo "<td>" . htmlspecialchars($playerStats['winPlace']) . "</td>";
|
||||
echo "</tr>";
|
||||
}
|
||||
<tr>
|
||||
<!-- <th>Match Date</th> -->
|
||||
<tr>
|
||||
<th>Player Name</th>
|
||||
<th>Kills</th>
|
||||
<th>Damage Dealt</th>
|
||||
<th>Time Survived</th>
|
||||
<th>Rank</th>
|
||||
</tr>
|
||||
</tr>
|
||||
|
||||
|
||||
<?php
|
||||
// Check if a match ID is provided in the GET request
|
||||
if (isset($_GET['matchid'])) {
|
||||
$matchId = $_GET['matchid'];
|
||||
$filename = "data/matches/" . $matchId . ".json";
|
||||
|
||||
// Check if the JSON file for the given match ID exists
|
||||
if (file_exists($filename)) {
|
||||
// Read and decode the JSON file
|
||||
$jsonData = json_decode(file_get_contents($filename), true);
|
||||
|
||||
foreach ($jsonData['included'] as $includedItem) {
|
||||
if ($includedItem['type'] == "participant") {
|
||||
$playerStats = $includedItem['attributes']['stats'];
|
||||
echo "<tr>";
|
||||
echo "<td>" . htmlspecialchars($playerStats['name']) . "</td>";
|
||||
echo "<td>" . htmlspecialchars($playerStats['kills']) . "</td>";
|
||||
echo "<td>" . htmlspecialchars($playerStats['damageDealt']) . "</td>";
|
||||
echo "<td>" . htmlspecialchars($playerStats['timeSurvived']) . "</td>";
|
||||
echo "<td>" . htmlspecialchars($playerStats['winPlace']) . "</td>";
|
||||
echo "</tr>";
|
||||
}
|
||||
|
||||
echo "</table>";
|
||||
} else {
|
||||
echo "JSON file not found for the given match ID.";
|
||||
}
|
||||
|
||||
echo "</table>";
|
||||
} else {
|
||||
echo "No match ID provided.";
|
||||
echo "JSON file not found for the given match ID.";
|
||||
}
|
||||
?>
|
||||
</tbody>
|
||||
} else {
|
||||
echo "No match ID provided.";
|
||||
}
|
||||
?>
|
||||
|
||||
</table>
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue