Merge pull request #123 from OpzekerIT/dev

Clan info updated with clanmembers and clickable to latest matches
This commit is contained in:
Lanta 2023-11-16 13:57:21 +01:00 committed by GitHub
commit 0ac16cf29c
3 changed files with 25 additions and 24 deletions

View file

@ -1,26 +1,23 @@
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
?>
<!DOCTYPE html>
<html lang="en">
<?php include './includes/head.php'; ?>
<body>
<?php include './includes/navigation.php'; ?>
<header>
<img src="./images/banner2.png" alt="banner" class="banner">
<?php include './includes/navigation.php'; ?>
<header>
<img src="./images/banner2.png" alt="banner" class="banner">
</header>
<main>
<section>
<h2>Clan Stats</h2>
<?php
<main>
<section>
<h2>Clan Stats</h2>
<?php
include './config/config.php';
// Load clan data from claninfo.json
$clanInfoPath = './data/claninfo.json';
$clanmembersfile = './config/clanmembers.json';
$clanmembers = json_decode(file_get_contents($clanmembersfile), true);
if (file_exists($clanInfoPath)) {
$clan = json_decode(file_get_contents($clanInfoPath), true);
if (isset($clan) && !empty($clan)) {
@ -29,6 +26,10 @@ error_reporting(E_ALL);
foreach ($clan as $key => $value) {
echo "<tr><td>" . htmlspecialchars($key) . "</td><td>" . htmlspecialchars($value) . "</td></tr>";
}
foreach ($clanmembers['clanMembers'] as $value) {
echo "<tr><td><a href='latestmatches.php?selected_player=" . htmlspecialchars($value) . "'>name</a></td><td><a href='latestmatches.php?selected_player=" . htmlspecialchars($value) . "'>" . htmlspecialchars($value) . "</a></td></tr>";
}
echo "</table>";
} else {
echo "<p>No clan attributes available</p>";
@ -36,11 +37,12 @@ error_reporting(E_ALL);
} else {
echo "<p>Clan info file missing</p>";
}
?>
</section>
</main>
?>
</section>
</main>
<?php include './includes/footer.php'; ?>
<?php include './includes/footer.php'; ?>
</body>
</html>
</html>

View file

@ -10,7 +10,6 @@
"SquadKiller101",
"Pettie1972",
"HeteKip",
"Shepherders",
"WackyJacky101"
"Shepherders"
]
}

View file

@ -21,10 +21,10 @@ error_reporting(E_ALL);
$players_data = json_decode(file_get_contents('./data/player_lifetime_data.json'), true);
$selected_mode = isset($_POST['game_mode']) ? $_POST['game_mode'] : 'squad';
$selected_mode = isset($_GET['game_mode']) ? $_GET['game_mode'] : 'squad';
// Form to select game mode
echo "<form method='post' action=''>
echo "<form method='get' action=''>
<input type='submit' name='game_mode' value='solo' class='btn'>
<input type='submit' name='game_mode' value='duo' class='btn'>
<input type='submit' name='game_mode' value='squad' class='btn'>
@ -35,7 +35,7 @@ error_reporting(E_ALL);
</form><br>";
// Buttons for each player
echo "<form method='post' action=''>";
echo "<form method='get' action=''>";
foreach ($players_data[$selected_mode] as $player_name => $player_details) {
echo "<button type='submit' name='selected_player' value='$player_name' class='btn' >$player_name</button>";
@ -43,7 +43,7 @@ error_reporting(E_ALL);
echo "<input type='hidden' name='game_mode' value='$selected_mode'>";
echo "</form><br>";
$selected_player = $_POST['selected_player'] ?? array_key_first($players_data[$selected_mode]);
$selected_player = $_GET['selected_player'] ?? array_key_first($players_data[$selected_mode]);
// Fetch the player stats based on game mode and selected player
if (isset($players_data[$selected_mode][$selected_player])) {