Bläddra i källkod

Ausgabe der Spieletyps

erdo 18 timmar sedan
förälder
incheckning
6c4be09f1d
1 ändrade filer med 13 tillägg och 6 borttagningar
  1. 13 6
      index.php

+ 13 - 6
index.php

@@ -26,8 +26,12 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['add_score'])) {
 }
 
 // --- DATEN ABFRAGEN ---
-// ÄNDERUNG HIER: Sortierung von id DESC auf titel ASC gesetzt
-$stmtGames = $pdo->query("SELECT * FROM spiele ORDER BY titel ASC");
+// ÄNDERUNG: JOIN hinzugefügt, um den Typ-Namen zu erhalten
+$sqlGames = "SELECT s.*, t.bezeichnung as typ_name 
+             FROM spiele s 
+             LEFT JOIN game_typen t ON s.typ_id = t.id 
+             ORDER BY s.titel ASC";
+$stmtGames = $pdo->query($sqlGames);
 $exitGames = $stmtGames->fetchAll(PDO::FETCH_ASSOC);
 
 $stmtAllPlayers = $pdo->query("SELECT * FROM spieler ORDER BY name ASC");
@@ -61,7 +65,6 @@ $allScores = $pdo->query($sqlScores)->fetchAll();
         body { font-family: 'Segoe UI', sans-serif; background: var(--bg); color: var(--text); margin: 0; padding-bottom: 120px; transition: 0.3s; }
         .container { max-width: 1200px; margin: auto; padding: 20px; }
         
-        /* Bestätigungs-Banner */
         .alert { 
             background: var(--success); color: white; padding: 15px; border-radius: 8px; 
             margin-bottom: 20px; text-align: center; font-weight: bold;
@@ -99,7 +102,6 @@ $allScores = $pdo->query($sqlScores)->fetchAll();
         .form-section, .info-section { background: var(--card); padding: 20px; border-radius: 12px; border: 1px solid var(--border); }
         .highlight-border { border-color: var(--accent); }
         
-        /* Archiv-Link Styling */
         .info-section a { color: var(--accent); text-decoration: none; display: block; padding: 10px; border: 1px dashed var(--border); border-radius: 8px; text-align: center; transition: 0.2s; }
         .info-section a:hover { background: var(--bg); border-color: var(--accent); }
 
@@ -175,8 +177,13 @@ $allScores = $pdo->query($sqlScores)->fetchAll();
             <h2>🎯 Ergebnis eintragen</h2>
             <form method="POST" action="index.php">
                 <select name="spiel_id" required>
-                    <?php foreach ($exitGames as $game): ?>
-                        <option value="<?= $game['id'] ?>"><?= htmlspecialchars($game['titel']) ?></option>
+                    <option value="">-- Spiel wählen --</option>
+                    <?php foreach ($exitGames as $game): 
+                        $display_typ = $game['typ_name'] ?: 'Unbekannt';
+                    ?>
+                        <option value="<?= $game['id'] ?>">
+                            <?= htmlspecialchars($game['titel']) ?> (<?= htmlspecialchars($display_typ) ?>)
+                        </option>
                     <?php endforeach; ?>
                 </select>
                 <select name="spieler_id" required>