matchinfo

This commit is contained in:
Lanta 2023-11-14 22:20:42 +01:00
parent d87267f5cf
commit d6a0ad0bc3

View file

@ -37,52 +37,57 @@ $lastMatches = array_slice($allMatches, 0, 8);
<section> <section>
<h2>Latest Matches</h2> <h2>Latest Matches</h2>
<table class='sortable'>
<tr>
<!-- <th>Match Date</th> -->
<th>Player Name</th>
<th>Kills</th>
<th>Damage Dealt</th>
<th>Time Survived</th>
<th>Rank</th>
</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 <?php
if (file_exists($filename)) { // Check if a match ID is provided in the GET request
// Read and decode the JSON file if (isset($_GET['matchid'])) {
$jsonData = json_decode(file_get_contents($filename), true); $matchId = $_GET['matchid'];
$filename = "data/matches/" . $matchId . ".json";
foreach ($jsonData['included'] as $includedItem) { // Check if the JSON file for the given match ID exists
if ($includedItem['type'] == "participant") { if (file_exists($filename)) {
$playerStats = $includedItem['attributes']['stats']; // Read and decode the JSON file
echo "<tr>"; $jsonData = json_decode(file_get_contents($filename), true);
echo "<td>" . htmlspecialchars($playerStats['name']) . "</td>"; $matchinfo = $jsonData['data']['attributes'];
echo "<td>" . htmlspecialchars($playerStats['kills']) . "</td>"; $matchdata = $jsonData['data']
echo "<td>" . htmlspecialchars($playerStats['damageDealt']) . "</td>"; echo "<table class='sortable'><tr><th>matchType</th><th>duration</th><th>gameMode</th><th>mapName</th><th>createdAt</th><th>id</th></tr>";
echo "<td>" . htmlspecialchars($playerStats['timeSurvived']) . "</td>"; echo "<tr>";
echo "<td>" . htmlspecialchars($playerStats['winPlace']) . "</td>"; echo "<td>" . htmlspecialchars($matchinfo['matchType']) . "</td>";
echo "</tr>"; echo "<td>" . htmlspecialchars($matchinfo['duration']) . "</td>";
} echo "<td>" . htmlspecialchars($matchinfo['gameMode']) . "</td>";
echo "<td>" . htmlspecialchars($matchinfo['mapName']) . "</td>";
echo "<td>" . htmlspecialchars($matchinfo['createdAt']) . "</td>";
echo "<td>" . htmlspecialchars($$matchdata['id']) . "</td>";
echo "</tr>";
echo "</table>";
echo "<table class='sortable'><tr><th>Player Name</th><th>Kills</th><th>Damage Dealt</th><th>Time Survived</th><th>Rank</th></tr>";
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 { } else {
echo "No match ID provided."; echo "JSON file not found for the given match ID.";
} }
?> } else {
echo "No match ID provided.";
}
?>
</table> </table>