98 lines
3.6 KiB
PHP
98 lines
3.6 KiB
PHP
<?php
|
|
require_once 'db/config.php';
|
|
|
|
$playerName = $_GET['player'] ?? null;
|
|
|
|
if (!$playerName) {
|
|
header("Location: results.php");
|
|
exit;
|
|
}
|
|
|
|
$rounds = [];
|
|
try {
|
|
$pdo = db();
|
|
$stmt = $pdo->prepare("
|
|
SELECT s.*, c.name as course_name
|
|
FROM scores s
|
|
JOIN courses c ON s.course_id = c.id
|
|
WHERE s.player_name = :player_name
|
|
ORDER BY s.played_at DESC
|
|
");
|
|
$stmt->execute([':player_name' => $playerName]);
|
|
$rounds = $stmt->fetchAll();
|
|
} catch (PDOException $e) {
|
|
// Handle DB error
|
|
}
|
|
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Player Stats - <?php echo htmlspecialchars($playerName); ?></title>
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
|
|
<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>
|
|
<div class="collapse navbar-collapse">
|
|
<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="results.php">Results</a></li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
</nav>
|
|
|
|
<div class="container mt-5">
|
|
<h1 class="mb-4">Stats for <?php echo htmlspecialchars($playerName); ?></h1>
|
|
|
|
<?php if (empty($rounds)): ?>
|
|
<div class="alert alert-warning">No rounds found for this player.</div>
|
|
<?php else: ?>
|
|
<?php foreach ($rounds as $round): ?>
|
|
<div class="card mb-4">
|
|
<div class="card-header">
|
|
<h5><?php echo htmlspecialchars($round['course_name']); ?> - <?php echo date("M d, Y", strtotime($round['played_at'])); ?></h5>
|
|
</div>
|
|
<div class="card-body">
|
|
<table class="table table-bordered">
|
|
<thead>
|
|
<tr>
|
|
<th>Hole</th>
|
|
<?php for ($i = 1; $i <= $round['holes_played']; $i++): ?>
|
|
<th><?php echo $i; ?></th>
|
|
<?php endfor; ?>
|
|
<th>Total</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<tr>
|
|
<td>Score</td>
|
|
<?php for ($i = 1; $i <= $round['holes_played']; $i++): ?>
|
|
<td><?php echo $round["hole_{$i}_score"]; ?></td>
|
|
<?php endfor; ?>
|
|
<td><?php echo $round['total_score']; ?></td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
<?php endif; ?>
|
|
</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>
|