gespielte_spiele.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. include 'db_config.php';
  3. $sql = "SELECT DISTINCT sp.* FROM spiele sp
  4. JOIN scores sc ON sp.id = sc.spiel_id
  5. ORDER BY sp.titel ASC";
  6. $stmt = $pdo->query($sql);
  7. $playedGames = $stmt->fetchAll();
  8. ?>
  9. <!DOCTYPE html>
  10. <html lang="de">
  11. <head>
  12. <meta charset="UTF-8">
  13. <title>Gespielte Spiele</title>
  14. <style>
  15. /* THEME VARIABLEN */
  16. :root {
  17. --bg: #f4f7f6; --card: #ffffff; --text: #333; --border: #ddd; --accent: #e67e22;
  18. }
  19. .dark-theme {
  20. --bg: #121212cf; --card: #1e1e1e; --text: #ffffff; --border: #333;
  21. }
  22. body { font-family: 'Segoe UI', sans-serif; background: var(--bg); color: var(--text); padding: 20px; transition: 0.3s; }
  23. header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
  24. .grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 20px; }
  25. .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); }
  26. .item img { width: 100%; border-radius: 4px; height: 150px; object-fit: cover; background: #2a2a2a; }
  27. h1 { color: var(--accent); margin: 0; }
  28. .back { color: var(--accent); text-decoration: none; font-weight: bold; border: 1px solid var(--accent); padding: 5px 15px; border-radius: 6px; }
  29. .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; }
  30. </style>
  31. <script>
  32. if (localStorage.getItem('theme') === 'dark') document.documentElement.classList.add('dark-theme');
  33. </script>
  34. </head>
  35. <body>
  36. <header>
  37. <a href="index.php" class="back">← Dashboard</a>
  38. <div style="display: flex; align-items: center; gap: 15px;">
  39. <button onclick="toggleTheme()" class="theme-toggle" id="theme-icon">🌙</button>
  40. </div>
  41. </header>
  42. <h1>📂 Gelöste Abenteuer</h1>
  43. <p style="margin-bottom: 30px; opacity: 0.8;">Diese Spiele wurden bereits erfolgreich beendet.</p>
  44. <div class="grid">
  45. <?php foreach ($playedGames as $game): ?>
  46. <div class="item">
  47. <img src="<?= htmlspecialchars($game['bild_url']) ?>" onerror="this.src='https://via.placeholder.com/200x150?text=Kein+Bild'">
  48. <p style="font-weight: bold; margin-top: 10px;"><?= htmlspecialchars($game['titel']) ?></p>
  49. </div>
  50. <?php endforeach; ?>
  51. </div>
  52. <script>
  53. function toggleTheme() {
  54. const isDark = document.documentElement.classList.toggle('dark-theme');
  55. localStorage.setItem('theme', isDark ? 'dark' : 'light');
  56. document.getElementById('theme-icon').innerText = isDark ? '☀️' : '🌙';
  57. }
  58. // Icon beim Laden anpassen
  59. if (localStorage.getItem('theme') === 'dark') {
  60. document.getElementById('theme-icon').innerText = '☀️';
  61. }
  62. </script>
  63. </body>
  64. </html>