last 5 matches total
This commit is contained in:
parent
e3ee038477
commit
20115d3e09
1 changed files with 32 additions and 22 deletions
54
index.php
54
index.php
|
|
@ -3,10 +3,22 @@
|
||||||
$jsonData = file_get_contents('data/player_matches.json');
|
$jsonData = file_get_contents('data/player_matches.json');
|
||||||
$playersData = json_decode($jsonData, true);
|
$playersData = json_decode($jsonData, true);
|
||||||
|
|
||||||
// Function to get the last 5 matches for a player
|
// Combine matches from all players
|
||||||
function getLastMatches($player) {
|
$allMatches = [];
|
||||||
return array_slice($player['player_matches'], -5);
|
foreach ($playersData as $player) {
|
||||||
|
foreach ($player['player_matches'] as $match) {
|
||||||
|
$match['playername'] = $player['playername']; // Add playername to each match for reference
|
||||||
|
$allMatches[] = $match;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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, 5);
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
|
|
@ -27,8 +39,9 @@ function getLastMatches($player) {
|
||||||
|
|
||||||
<main>
|
<main>
|
||||||
<section>
|
<section>
|
||||||
|
<h2>Welcome to DTCH - PUBG Clan</h2>
|
||||||
|
|
||||||
<table border="1">
|
<table border="1">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Match Date</th>
|
<th>Match Date</th>
|
||||||
|
|
@ -44,28 +57,25 @@ function getLastMatches($player) {
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<?php
|
<?php
|
||||||
foreach($playersData as $player) {
|
foreach($lastMatches as $match) {
|
||||||
$matches = getLastMatches($player);
|
?>
|
||||||
foreach($matches as $match) {
|
<tr>
|
||||||
?>
|
<td><?php echo date("Y-m-d", strtotime($match['createdAt'])); ?></td>
|
||||||
<tr>
|
<td><?php echo $match['playername']; ?></td>
|
||||||
<td><?php echo date("Y-m-d", strtotime($match['createdAt'])); ?></td>
|
<td><?php echo $match['gameMode']; ?></td>
|
||||||
<td><?php echo $player['playername']; ?></td>
|
<td><?php echo $match['matchType']; ?></td>
|
||||||
<td><?php echo $match['gameMode']; ?></td>
|
<td><?php echo $match['mapName']; ?></td>
|
||||||
<td><?php echo $match['matchType']; ?></td>
|
<td><?php echo $match['stats']['kills']; ?></td>
|
||||||
<td><?php echo $match['mapName']; ?></td>
|
<td><?php echo $match['stats']['damageDealt']; ?></td>
|
||||||
<td><?php echo $match['stats']['kills']; ?></td>
|
<td><?php echo gmdate("H:i:s", $match['stats']['timeSurvived']); ?></td>
|
||||||
<td><?php echo $match['stats']['damageDealt']; ?></td>
|
<td><?php echo $match['stats']['winPlace']; ?></td>
|
||||||
<td><?php echo gmdate("H:i:s", $match['stats']['timeSurvived']); ?></td>
|
</tr>
|
||||||
<td><?php echo $match['stats']['winPlace']; ?></td>
|
<?php
|
||||||
</tr>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<h2>Welcome to DTCH - PUBG Clan</h2>
|
|
||||||
<p>Join us on our Discord:</p>
|
<p>Join us on our Discord:</p>
|
||||||
<a href="https://discord.gg/wMXsB3ZmNA" target="_blank" rel="noopener noreferrer">
|
<a href="https://discord.gg/wMXsB3ZmNA" target="_blank" rel="noopener noreferrer">
|
||||||
<img src="./media/discordlogo.png" alt="Discord Logo" class="discord-logo">
|
<img src="./media/discordlogo.png" alt="Discord Logo" class="discord-logo">
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue