Merge pull request 'changed the total score to a station ranking on the homepage' (#3) from dev into main

Reviewed-on: #3
This commit was merged in pull request #3.
This commit is contained in:
2022-09-18 17:34:05 +00:00
3 changed files with 29 additions and 2 deletions

View File

@@ -14,11 +14,11 @@
<h1><span>Punktesystem Kreispokalwettbewerb</span></h1>
</div>
<div class="home">
<h2>Gesamtergebnis</h2>
<h2>Stationsranking</h2>
</div>
<div class="home-menu-table table-div">
<table id="table">
<?php load_total_score($con); ?>
<?php load_station_ranking($con); ?>
</table>
</div>
</div>

View File

@@ -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");

View File

@@ -78,6 +78,22 @@ function load_total_score($con) {
echo "</tbody>\n";
}
function load_station_ranking($con) {
echo "<thead> \n
<th scope=\"col\">Station</th>\n
<th scope=\"col\">Gesamtpunkte</th>\n
</thead>\n
<tbody>\n";
$stmt = get_station_ranking($con);
foreach($stmt->fetchAll() as $row) {
echo "<tr>\n";
echo "<td>" . $row['Stationsname'] . "</td>\n";
echo "<td>" . $row['Gesamtpunkte'] . "</td>\n";
echo "</tr>\n";
}
echo "</tbody>\n";
}
function load_options_stations($con, $session, $stats) {
$stmt = get_stations_all($con);
if ($session == "total-score"){