The following files exists in this folder. Click to view.
match_history.php71 lines ASCII Windows (CRLF) 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
<?php
require "auth.php";
require "database.php";
requireLogin();
$ladderID = $_GET["ladder_id"] ?? null;
if (!$ladderID) {
die("No ladder selected");
}
$stmt = $conn->prepare(
"SELECT m.PlayedAt,
p1.Username AS Player1,
p2.Username AS Player2,
w.Username AS Winner
FROM Matches m
JOIN Players p1 ON m.Player1ID = p1.PlayerID
JOIN Players p2 ON m.Player2ID = p2.PlayerID
JOIN Players w ON m.WinnerID = w.PlayerID
WHERE m.LadderID = ?
ORDER BY m.PlayedAt DESC"
);
$stmt->execute([$ladderID]);
$matches = $stmt->fetchAll();
?>
<!DOCTYPE html>
<html>
<head>
<title>Match History</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<div class="container mt-5">
<h2>Match History</h2>
<?php if (!$matches): ?>
<div class="alert alert-info">
No matches found for this ladder.
</div>
<?php else: ?>
<table class="table table-striped">
<thead>
<tr>
<th>Date</th>
<th>Player 1</th>
<th>Player 2</th>
<th>Winner</th>
</tr>
</thead>
<tbody>
<?php foreach ($matches as $m): ?>
<tr>
<td><?= htmlspecialchars($m["PlayedAt"]) ?></td>
<td><?= htmlspecialchars($m["Player1"]) ?></td>
<td><?= htmlspecialchars($m["Player2"]) ?></td>
<td><strong><?= htmlspecialchars($m["Winner"]) ?></strong></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php endif; ?>
<a href="javascript:history.back()" class="btn btn-secondary">Back</a>
</div>
</body>
</html>