147 lines
6.3 KiB
PHP
147 lines
6.3 KiB
PHP
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Live Results - Golf Tournament</title>
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
|
|
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&display=swap">
|
|
<link rel="stylesheet" href="assets/css/custom.css">
|
|
</head>
|
|
<body>
|
|
|
|
<nav class="navbar navbar-expand-lg navbar-dark bg-primary">
|
|
<div class="container">
|
|
<a class="navbar-brand" href="index.php">Golf Tournament</a>
|
|
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
|
|
<span class="navbar-toggler-icon"></span>
|
|
</button>
|
|
<div class="collapse navbar-collapse" id="navbarNav">
|
|
<ul class="navbar-nav ms-auto">
|
|
<li class="nav-item">
|
|
<a class="nav-link" href="index.php">Home</a>
|
|
</li>
|
|
<li class="nav-item">
|
|
<a class="nav-link" href="add_score.php">Add Score</a>
|
|
</li>
|
|
<li class="nav-item">
|
|
<a class="nav-link" href="admin.php">Admin</a>
|
|
</li>
|
|
<li class="nav-item">
|
|
<a class="nav-link" href="coach.php">Coach</a>
|
|
</li>
|
|
<li class="nav-item">
|
|
<a class="nav-link active" href="results.php">Results</a>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
</nav>
|
|
|
|
<div class="container mt-5">
|
|
<h1 class="text-center mb-4">Tournament Leaderboard</h1>
|
|
|
|
<div class="card shadow-sm">
|
|
<div class="card-body">
|
|
<h2 class="card-title">Individual Standings</h2>
|
|
<?php
|
|
require_once 'db/config.php';
|
|
try {
|
|
$pdo = db();
|
|
$stmt = $pdo->query("
|
|
SELECT player_name, team_name, SUM(total_score) as total_score, SUM(total_to_par) as total_to_par
|
|
FROM scores
|
|
GROUP BY player_name, team_name
|
|
ORDER BY total_to_par ASC
|
|
");
|
|
$results = $stmt->fetchAll();
|
|
} catch (PDOException $e) {
|
|
$results = [];
|
|
}
|
|
?>
|
|
<table class="table table-striped">
|
|
<thead>
|
|
<tr>
|
|
<th>Rank</th>
|
|
<th>Player</th>
|
|
<th>Team</th>
|
|
<th>Total Score</th>
|
|
<th>To Par</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php if (empty($results)): ?>
|
|
<tr>
|
|
<td colspan="5" class="text-center">No results yet.</td>
|
|
</tr>
|
|
<?php else: ?>
|
|
<?php foreach ($results as $index => $row): ?>
|
|
<tr>
|
|
<td><?php echo $index + 1; ?></td>
|
|
<td><a href="player.php?player=<?php echo urlencode($row['player_name']); ?>"><?php echo htmlspecialchars($row['player_name']); ?></a></td>
|
|
<td><?php echo htmlspecialchars($row['team_name']); ?></td>
|
|
<td><?php echo $row['total_score']; ?></td>
|
|
<td><?php echo ($row['total_to_par'] > 0 ? '+' : '') . $row['total_to_par']; ?></td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
<?php endif; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="card shadow-sm mt-4">
|
|
<div class="card-body">
|
|
<h2 class="card-title">Team Standings</h2>
|
|
<?php
|
|
try {
|
|
$stmt = $pdo->query("
|
|
SELECT team_name, SUM(total_score) as total_score
|
|
FROM scores
|
|
WHERE team_name IS NOT NULL AND team_name != ''
|
|
GROUP BY team_name
|
|
ORDER BY total_score ASC
|
|
");
|
|
$team_results = $stmt->fetchAll();
|
|
} catch (PDOException $e) {
|
|
$team_results = [];
|
|
}
|
|
?>
|
|
<table class="table table-striped">
|
|
<thead>
|
|
<tr>
|
|
<th>Rank</th>
|
|
<th>Team</th>
|
|
<th>Total Score</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php if (empty($team_results)): ?>
|
|
<tr>
|
|
<td colspan="3" class="text-center">No team results yet.</td>
|
|
</tr>
|
|
<?php else: ?>
|
|
<?php foreach ($team_results as $index => $row): ?>
|
|
<tr>
|
|
<td><?php echo $index + 1; ?></td>
|
|
<td><?php echo htmlspecialchars($row['team_name']); ?></td>
|
|
<td><?php echo $row['total_score']; ?></td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
<?php endif; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<footer class="bg-light text-center text-lg-start mt-5">
|
|
<div class="text-center p-3" style="background-color: rgba(0, 0, 0, 0.05);">
|
|
© 2025 Golf Tournament
|
|
</div>
|
|
</footer>
|
|
|
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
|
|
</body>
|
|
</html>
|