From fc1c5f86218f3db6ab5899624db0bf4366577833 Mon Sep 17 00:00:00 2001 From: Lanta Date: Tue, 14 Nov 2023 21:09:20 +0100 Subject: [PATCH] table --- matchinfo.php | 122 ++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 88 insertions(+), 34 deletions(-) diff --git a/matchinfo.php b/matchinfo.php index 311fab7..0ca7865 100644 --- a/matchinfo.php +++ b/matchinfo.php @@ -1,38 +1,92 @@ "; - echo "Player NameKillsDamage DealtTime SurvivedRank"; - - // Loop through the JSON data to extract player stats - - foreach ($jsonData['included'] as $includedItem) { - if ($includedItem['type'] == "participant"){ - $playerStats = $includedItem['attributes']['stats']; - echo ""; - echo "" . htmlspecialchars($playerStats['name']) . ""; - echo "" . htmlspecialchars($playerStats['kills']) . ""; - echo "" . htmlspecialchars($playerStats['damageDealt']) . ""; - echo "" . htmlspecialchars($playerStats['timeSurvived']) . ""; - echo "" . htmlspecialchars($playerStats['winPlace']) . ""; - echo ""; - } - } - - echo ""; - } else { - echo "JSON file not found for the given match ID."; +// Combine matches from all players +$allMatches = []; +foreach ($playersData as $player) { + foreach ($player['player_matches'] as $match) { + $match['playername'] = $player['playername']; // Add playername to each match for reference + $allMatches[] = $match; } -} else { - echo "No match ID provided."; } -?> \ No newline at end of file + +// Sort matches by createdAt date +usort($allMatches, function ($a, $b) { + return strtotime($b['createdAt']) - strtotime($a['createdAt']); +}); + +// Get the last 5 matches +$lastMatches = array_slice($allMatches, 0, 8); + +?> + + + + + + + + +
+ +
+ +
+
+

Latest Matches

+ + + + + + + + + + "; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + } + } + + echo "
Player NameKillsDamage DealtTime SurvivedRank
" . htmlspecialchars($playerStats['name']) . "" . htmlspecialchars($playerStats['kills']) . "" . htmlspecialchars($playerStats['damageDealt']) . "" . htmlspecialchars($playerStats['timeSurvived']) . "" . htmlspecialchars($playerStats['winPlace']) . "
"; + } else { + echo "JSON file not found for the given match ID."; + } + } else { + echo "No match ID provided."; + } + ?> + + + + + +
+
+ + + + + + \ No newline at end of file