|
|
@@ -1,9 +1,23 @@
|
|
|
<?php
|
|
|
include 'db_config.php';
|
|
|
|
|
|
-$sql = "SELECT DISTINCT sp.* FROM spiele sp
|
|
|
+// --- 1. DATEN LADEN ---
|
|
|
+// Alle Spieler für den Filter laden
|
|
|
+$allTeams = $pdo->query("SELECT * FROM spieler ORDER BY name ASC")->fetchAll();
|
|
|
+
|
|
|
+// Filter-Logik
|
|
|
+$teamFilter = isset($_GET['team_id']) ? (int)$_GET['team_id'] : 0;
|
|
|
+
|
|
|
+$sql = "SELECT sp.*, sc.zeit, sc.hilfe, sc.sterne, s.name as team_name
|
|
|
+ FROM spiele sp
|
|
|
JOIN scores sc ON sp.id = sc.spiel_id
|
|
|
- ORDER BY sp.titel ASC";
|
|
|
+ JOIN spieler s ON sc.spieler_id = s.id";
|
|
|
+
|
|
|
+if ($teamFilter > 0) {
|
|
|
+ $sql .= " WHERE s.id = $teamFilter";
|
|
|
+}
|
|
|
+
|
|
|
+$sql .= " ORDER BY sp.titel ASC";
|
|
|
$stmt = $pdo->query($sql);
|
|
|
$playedGames = $stmt->fetchAll();
|
|
|
?>
|
|
|
@@ -13,7 +27,6 @@ $playedGames = $stmt->fetchAll();
|
|
|
<meta charset="UTF-8">
|
|
|
<title>Gespielte Spiele</title>
|
|
|
<style>
|
|
|
- /* THEME VARIABLEN */
|
|
|
:root {
|
|
|
--bg: #f4f7f6; --card: #ffffff; --text: #333; --border: #ddd; --accent: #e67e22;
|
|
|
}
|
|
|
@@ -22,16 +35,27 @@ $playedGames = $stmt->fetchAll();
|
|
|
}
|
|
|
|
|
|
body { font-family: 'Segoe UI', sans-serif; background: var(--bg); color: var(--text); padding: 20px; transition: 0.3s; }
|
|
|
-
|
|
|
header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
|
|
|
|
|
|
- .grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 20px; }
|
|
|
- .item { background: var(--card); padding: 10px; border-radius: 8px; text-align: center; border: 1px solid var(--border); box-shadow: 0 4px 10px rgba(0,0,0,0.1); }
|
|
|
- .item img { width: 100%; border-radius: 4px; height: 150px; object-fit: cover; background: #2a2a2a; }
|
|
|
+ /* Filter Bereich */
|
|
|
+ .filter-bar { background: var(--card); padding: 15px; border-radius: 12px; border: 1px solid var(--border); margin-bottom: 25px; display: flex; align-items: center; gap: 15px; }
|
|
|
+ select { padding: 8px 15px; border-radius: 6px; border: 1px solid var(--border); background: var(--bg); color: var(--text); cursor: pointer; }
|
|
|
+
|
|
|
+ .grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 20px; }
|
|
|
+ .item { background: var(--card); border-radius: 12px; text-align: center; border: 1px solid var(--border); box-shadow: 0 4px 10px rgba(0,0,0,0.1); overflow: hidden; position: relative; }
|
|
|
+ .item img { width: 100%; height: 160px; object-fit: cover; background: #2a2a2a; border-bottom: 1px solid var(--border); }
|
|
|
|
|
|
+ /* Ergebnis-Overlay / Badge */
|
|
|
+ .stats { padding: 12px; }
|
|
|
+ .team-badge { font-size: 0.75em; background: var(--accent); color: white; padding: 2px 8px; border-radius: 10px; margin-bottom: 5px; display: inline-block; }
|
|
|
+ .game-title { font-weight: bold; display: block; margin-bottom: 8px; font-size: 1em; }
|
|
|
+
|
|
|
+ .result-row { display: flex; justify-content: space-around; font-size: 0.85em; border-top: 1px solid var(--border); padding-top: 8px; margin-top: 8px; }
|
|
|
+ .res-item span { display: block; opacity: 0.6; font-size: 0.8em; }
|
|
|
+ .res-item b { color: var(--accent); }
|
|
|
+
|
|
|
h1 { color: var(--accent); margin: 0; }
|
|
|
.back { color: var(--accent); text-decoration: none; font-weight: bold; border: 1px solid var(--accent); padding: 5px 15px; border-radius: 6px; }
|
|
|
-
|
|
|
.theme-toggle { background: var(--card); border: 1px solid var(--border); color: var(--text); padding: 8px 12px; border-radius: 20px; cursor: pointer; font-size: 1.1rem; }
|
|
|
</style>
|
|
|
<script>
|
|
|
@@ -48,17 +72,43 @@ $playedGames = $stmt->fetchAll();
|
|
|
</header>
|
|
|
|
|
|
<h1>📂 Gelöste Abenteuer</h1>
|
|
|
- <p style="margin-bottom: 30px; opacity: 0.8;">Diese Spiele wurden bereits erfolgreich beendet.</p>
|
|
|
+
|
|
|
+ <div class="filter-bar">
|
|
|
+ <span>Team-Filter:</span>
|
|
|
+ <form id="filterForm">
|
|
|
+ <select name="team_id" onchange="document.getElementById('filterForm').submit()">
|
|
|
+ <option value="0">-- Alle Teams anzeigen --</option>
|
|
|
+ <?php foreach ($allTeams as $t): ?>
|
|
|
+ <option value="<?= $t['id'] ?>" <?= $teamFilter == $t['id'] ? 'selected' : '' ?>>
|
|
|
+ <?= htmlspecialchars($t['name']) ?>
|
|
|
+ </option>
|
|
|
+ <?php endforeach; ?>
|
|
|
+ </select>
|
|
|
+ </form>
|
|
|
+ </div>
|
|
|
|
|
|
<div class="grid">
|
|
|
<?php foreach ($playedGames as $game): ?>
|
|
|
<div class="item">
|
|
|
- <img src="<?= htmlspecialchars($game['bild_url']) ?>" onerror="this.src='https://via.placeholder.com/200x150?text=Kein+Bild'">
|
|
|
- <p style="font-weight: bold; margin-top: 10px;"><?= htmlspecialchars($game['titel']) ?></p>
|
|
|
+ <img src="<?= htmlspecialchars($game['bild_url']) ?>" onerror="this.src='https://via.placeholder.com/220x160?text=Kein+Bild'">
|
|
|
+ <div class="stats">
|
|
|
+ <span class="team-badge"><?= htmlspecialchars($game['team_name']) ?></span>
|
|
|
+ <span class="game-title"><?= htmlspecialchars($game['titel']) ?></span>
|
|
|
+
|
|
|
+ <div class="result-row">
|
|
|
+ <div class="res-item"><span>Zeit</span><b><?= $game['zeit'] ?> Min</b></div>
|
|
|
+ <div class="res-item"><span>Hilfe</span><b><?= $game['hilfe'] ?></b></div>
|
|
|
+ <div class="res-item"><span>Sterne</span><b>⭐ <?= $game['sterne'] ?></b></div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
<?php endforeach; ?>
|
|
|
</div>
|
|
|
|
|
|
+ <?php if (empty($playedGames)): ?>
|
|
|
+ <p style="text-align: center; margin-top: 50px; opacity: 0.5;">Keine Spiele für dieses Team gefunden.</p>
|
|
|
+ <?php endif; ?>
|
|
|
+
|
|
|
<script>
|
|
|
function toggleTheme() {
|
|
|
const isDark = document.documentElement.classList.toggle('dark-theme');
|
|
|
@@ -66,7 +116,6 @@ $playedGames = $stmt->fetchAll();
|
|
|
document.getElementById('theme-icon').innerText = isDark ? '☀️' : '🌙';
|
|
|
}
|
|
|
|
|
|
- // Icon beim Laden anpassen
|
|
|
if (localStorage.getItem('theme') === 'dark') {
|
|
|
document.getElementById('theme-icon').innerText = '☀️';
|
|
|
}
|