query("SELECT id, name FROM courses ORDER BY name"); $courses = $stmt->fetchAll(); $stmt = $pdo->query("SELECT p.id, p.team_id, p.name AS player_name, t.name AS team_name FROM players p JOIN teams t ON p.team_id = t.id ORDER BY team_name, player_name"); $players = $stmt->fetchAll(); } catch (PDOException $e) { // If something goes wrong, we'll have empty arrays. // For debugging, you might want to log the error: // error_log($e->getMessage()); } ?>