setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); // Get the division from the page $division = $_GET["division"]; // If we want all the data, we don't need to select a division in the SQL query if ($division == "all") { $sqlGetTourneyInfo = $conn->prepare("SELECT tournamentName,tournamentDate,tournamentDivision,numPlayers,winningTeamName,winner1,winner2,winner3,winner4 FROM " . $tournamentDataTableName . " ORDER BY tournamentDate DESC LIMIT $tourneyCardLimit"); } else { $sqlGetTourneyInfo = $conn->prepare("SELECT tournamentName,tournamentDate,tournamentDivision,numPlayers,winningTeamName,winner1,winner2,winner3,winner4 FROM " . $tournamentDataTableName . " WHERE tournamentDivision='" . $division . "' ORDER BY tournamentDate DESC LIMIT $tourneyCardLimit"); } $sqlGetTourneyInfo->execute(); } catch (PDOException $e) { // failed connection echo "Connection failed: " . $e->getMessage(); } $tourneyResults = $sqlGetTourneyInfo->fetchAll(PDO::FETCH_ASSOC); ?>