Added "all" to years display to show ALL results

This commit is contained in:
Taylor Courage 2025-03-07 22:20:28 -05:00
parent 2f57207109
commit 491c34cc93
3 changed files with 21 additions and 6 deletions

View File

@ -18,12 +18,18 @@ try { // Try opening the SQL database connection
} else { } else {
$getMonth = "MONTH(tournamentDate)=\"" . $_GET["month"] . "\" AND "; $getMonth = "MONTH(tournamentDate)=\"" . $_GET["month"] . "\" AND ";
} }
// Grab year and division // Grab year similar to above
$year = $_GET["year"]; if ($_GET["year"] == "all") {
$getYear = "";
} else {
$getYear = "YEAR(tournamentDate)=\"" . $_GET["year"] . "\" AND ";
}
// Grab division
$division = $_GET["division"]; $division = $_GET["division"];
// Select all the winners from the table where the month, year, and division all match // Select all the winners from the table where the month, year, and division all match
$sqlGetTopWinnersList = $conn->prepare("SELECT winner1,winner2,winner3,winner4 FROM " . $tournamentDataTableName . " WHERE $getMonth YEAR(tournamentDate)=\"" . $year . "\" AND tournamentDivision=\"" . $division . "\""); $sqlGetTopWinnersList = $conn->prepare("SELECT winner1,winner2,winner3,winner4 FROM " . $tournamentDataTableName . " WHERE $getMonth $getYear tournamentDivision=\"" . $division . "\"");
$sqlGetTopWinnersList->execute(); $sqlGetTopWinnersList->execute();
// Fetch the results // Fetch the results

View File

@ -211,6 +211,7 @@ session_start();
?> ?>
</select> </select>
<select size="1" name="year" id="year" onchange="refreshDisplay()"> <select size="1" name="year" id="year" onchange="refreshDisplay()">
<option value="all">All</option>
<?php <?php
// This uses the years we grabbed earlier and ensures we're only showing // This uses the years we grabbed earlier and ensures we're only showing
// the years we have entries for // the years we have entries for

View File

@ -1,19 +1,27 @@
function refreshDisplay() { function refreshDisplay() {
// Grab the division buttons by their name
var divisionButtons = document.getElementsByName("division"); var divisionButtons = document.getElementsByName("division");
var currentDivision = ""; var currentDivision = "";
// Loop through the division buttons and see which one is checked
// Set the current division to that option
for (var i = 0; i < divisionButtons.length; i++) { for (var i = 0; i < divisionButtons.length; i++) {
if (divisionButtons[i].checked) { if (divisionButtons[i].checked) {
currentDivision = divisionButtons[i].value; currentDivision = divisionButtons[i].value;
} }
} }
var displayDiv = document.getElementById("divisionDisplay"); // If we set 'years' to all, then we should show all months too.
// This is effectively a "show all" setting
if (document.getElementById("year").value == "all") {
document.getElementById("month").value = "all";
}
// Grab the current division from the page
document.getElementById("divisionDisplay").innerHTML = currentDivision; document.getElementById("divisionDisplay").innerHTML = currentDivision;
console.log(currentDivision);
var html = "";
var html = ""; // placeholder for webpage
var image = ""; //get trophy image var image = ""; //get trophy image
html += "<div class=\"divisionPanel\">"; html += "<div class=\"divisionPanel\">";