From b2d27837ac4791da8fc6849db251a036a14701a2 Mon Sep 17 00:00:00 2001 From: Taylor Courage Date: Thu, 6 Mar 2025 06:30:50 -0500 Subject: [PATCH] - Added basic display for results, needs work - Added new tool to tools.js used to checking if a page is loaded in a frame or by itself - Removed old division-based .html displays, no longer relevant --- display/general_results.php | 120 ++++++++++++++++++++++++++++++++++++ index.php | 12 +--- intermediate.html | 65 ------------------- main.html | 45 -------------- open.html | 32 ---------- scripts/tools.js | 13 ++++ styles/data_display.css | 7 +++ 7 files changed, 142 insertions(+), 152 deletions(-) create mode 100644 display/general_results.php delete mode 100644 intermediate.html delete mode 100644 main.html delete mode 100644 open.html create mode 100644 styles/data_display.css diff --git a/display/general_results.php b/display/general_results.php new file mode 100644 index 0000000..ec0e19c --- /dev/null +++ b/display/general_results.php @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + GENERAL DATA + + + setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + + // Grab all our tourney and game results + // Prepare SQL + $sqlGetTourneyData = $conn->prepare("SELECT * FROM " . $tournamentDataTableName); + $sqlGetGameData = $conn->prepare("SELECT * FROM " . $gameDataTableName); + $sqlGetUserData = $conn->prepare("SELECT username FROM " . $userTableName); + + // Execute + $sqlGetTourneyData->execute(); + $sqlGetGameData->execute(); + $sqlGetUserData->execute(); + + // fetch rows + $tourneyData = $sqlGetTourneyData->fetchAll(PDO::FETCH_ASSOC); + $gameData = $sqlGetGameData->fetchAll(PDO::FETCH_ASSOC); + $userData = $sqlGetUserData->fetchAll(PDO::FETCH_NUM); + + // Initalize arrays to store tournament winner counts + // Total count + $totalTourneyWinners = array(); + $openTourneyWinners = array(); + $intermediateTourneyWinners = array(); + $mainTourneyWinners = array(); + + // Check the number of players for each entry + // Then, grab that many winners + foreach ($tourneyData as $data) { + for ($i = 1; $i <= $data["numPlayers"]; $i++) { + $winnerIndex = "winner" . $i; + $totalTourneyWinners[] = $data[$winnerIndex]; + if ($data["tournamentDivision"] == "open") { + $openTourneyWinners[] = $data[$winnerIndex]; + } + if ($data["tournamentDivision"] == "intermediate") { + $intermediateTourneyWinners[] = $data[$winnerIndex]; + } + if ($data["tournamentDivision"] == "main") { + $mainTourneyWinners[] = $data[$winnerIndex]; + } + } + } + + // Make 'unique' arrays, so we have TOTAL # played vs. # won + $totalUniqueTourneyWinners = array_unique($totalTourneyWinners); + $openUniqueTourneyWinners = array_unique($openTourneyWinners); + $intermediateUniqueTourneyWinners = array_unique($intermediateTourneyWinners); + $mainUniqueTourneyWinners = array_unique($mainTourneyWinners); + + + // Get counts of rows + $numGames = count($gameData); + $numTourneys = count($tourneyData); + $numUsers = count($userData); + $numTotalTourneyWinners = count($totalTourneyWinners); + $numOpenTourneyWinners = count($openTourneyWinners); + $numIntermediateTourneyWinners = count($intermediateTourneyWinners); + $numMainTourneyWinners = count($mainTourneyWinners); + $numUniqueTotalTourneyWinners = count($totalUniqueTourneyWinners); + $numUniqueOpenTourneyWinners = count($openUniqueTourneyWinners); + $numUniqueIntermediateTourneyWinners = count($intermediateUniqueTourneyWinners); + $numUniqueMainTourneyWinners = count($mainUniqueTourneyWinners); + + // Other data + $userIndex = $numUsers - 1; + $mostRecentUser = $userData[$userIndex][0]; + + + } catch (PDOException $e) { // failed connection + echo "Connection failed: " . $e->getMessage(); + } + + ?> + + +

General Information

+
+ Total registered users: $numUsers

"; + echo "

Most recent user: $mostRecentUser

"; + echo "

Number of Official Tournaments: $numTourneys

"; + echo "

Number of game results uploaded: $numGames

"; + echo "

Total # of titles won: $numTotalTourneyWinners

"; + echo "

# of winners: $numUniqueTotalTourneyWinners

"; + echo "

Total 'Open' titles won: $numOpenTourneyWinners

"; + echo "

# of winners: $numUniqueOpenTourneyWinners

"; + echo "

Total 'Intermediate' titles won: $numIntermediateTourneyWinners

"; + echo "

# of winners: $numUniqueIntermediateTourneyWinners

"; + echo "

Total 'Main' of titles won: $numMainTourneyWinners

"; + echo "

# of winners: $numUniqueMainTourneyWinners

"; + ?> +
+ + + + \ No newline at end of file diff --git a/index.php b/index.php index fa8b658..378694b 100644 --- a/index.php +++ b/index.php @@ -16,16 +16,7 @@ session_start();

Trojan's Trophy Room

Giveaway Disclaimer

-

Choose a division to see results!

- -

 

- +