From eacf3ce9b5bfa85ded6db5f67671c1e727b6074f Mon Sep 17 00:00:00 2001 From: Grisu Date: Sun, 18 Sep 2022 19:32:26 +0200 Subject: [PATCH] changed the total score to a station ranking on the homepage --- app/public/index.php | 4 ++-- app/scripts/database_queries.php | 11 +++++++++++ app/scripts/functions.php | 16 ++++++++++++++++ 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/app/public/index.php b/app/public/index.php index 81e1284..64c12a7 100644 --- a/app/public/index.php +++ b/app/public/index.php @@ -14,11 +14,11 @@

Punktesystem Kreispokalwettbewerb

-

Gesamtergebnis

+

Stationsranking

- +
diff --git a/app/scripts/database_queries.php b/app/scripts/database_queries.php index e03befa..c9bfbc8 100644 --- a/app/scripts/database_queries.php +++ b/app/scripts/database_queries.php @@ -96,6 +96,17 @@ function get_total_score($con) { } } +function get_station_ranking($con) { + try { + $stmt = $con->prepare("SELECT S.name as Stationsname, SUM(P.punkte) as Gesamtpunkte FROM Punkte as P, Station as S WHERE P.s_id = S.s_id AND S.gewertet = \"1\" GROUP BY S.s_id ORDER BY Gesamtpunkte DESC"); + $stmt->execute(); + $stmt->setFetchMode(PDO::FETCH_ASSOC); + return $stmt; + } catch(PDOException $e) { + handle_pdo_exception($e); + } +} + function get_station_name($con, $s_id) { try { $stmt = $con->prepare("SELECT name FROM Station WHERE s_id= :s_id"); diff --git a/app/scripts/functions.php b/app/scripts/functions.php index d4ccdfe..34e90bf 100644 --- a/app/scripts/functions.php +++ b/app/scripts/functions.php @@ -78,6 +78,22 @@ function load_total_score($con) { echo "\n"; } +function load_station_ranking($con) { + echo " \n + Station\n + Gesamtpunkte\n + \n + \n"; + $stmt = get_station_ranking($con); + foreach($stmt->fetchAll() as $row) { + echo "\n"; + echo "" . $row['Stationsname'] . "\n"; + echo "" . $row['Gesamtpunkte'] . "\n"; + echo "\n"; + } + echo "\n"; +} + function load_options_stations($con, $session, $stats) { $stmt = get_stations_all($con); if ($session == "total-score"){ -- 2.49.1