query("SELECT id, name FROM courses ORDER BY name"); $courses = $stmt->fetchAll(); $stmt = $pdo->query("SELECT p.id, p.player_name, t.team_name FROM players p JOIN teams t ON p.team_id = t.id ORDER BY t.team_name, p.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()); } ?>