diff --git a/app/public/statistik.php b/app/public/statistik.php index 8575432..282c31f 100644 --- a/app/public/statistik.php +++ b/app/public/statistik.php @@ -7,6 +7,24 @@ echo file_get_contents("html/header.html"); ?> + + +
+ + + + + + + + + +
MannschaftFeuerwehrGesamtpunkte
+
+ + execute(); $stmt->setFetchMode(PDO::FETCH_ASSOC); return $stmt; - } catch(PDOExeption $e) { + } catch(PDOException $e) { + handle_pdo_exception($e); + } +} + +function get_total_score($con) { + try { + $stmt = $con->prepare("SELECT M.name as Mannschaftsname, M.feuerwehr as Feuerwehr, SUM(P.punkte) as Gesamtpunkte FROM Punkte as P, Mannschaft as M WHERE P.m_id = M.m_id GROUP BY M.m_id ORDER BY Gesamtpunkte DESC"); + $stmt->execute(); + $stmt->setFetchMode(PDO::FETCH_ASSOC); + return $stmt; + } catch(PDOException $e) { handle_pdo_exception($e); } } \ No newline at end of file diff --git a/app/scripts/functions.php b/app/scripts/functions.php index 357e412..3d55cac 100644 --- a/app/scripts/functions.php +++ b/app/scripts/functions.php @@ -52,4 +52,15 @@ function load_teams_table($con) { echo "" . $row['feuerwehr'] . ""; echo ""; } +} + +function load_total_score($con) { + $stmt = get_total_score($con); + foreach($stmt->fetchAll() as $row) { + echo ""; + echo "" . $row['Mannschaftsname'] . ""; + echo "" . $row['Feuerwehr'] . ""; + echo "" . $row['Gesamtpunkte'] . ""; + echo ""; + } } \ No newline at end of file