show total score on statistic site

This commit is contained in:
2022-06-08 12:52:39 +02:00
parent 42cd6956b9
commit 0962a70cd7
3 changed files with 41 additions and 1 deletions

View File

@@ -7,6 +7,24 @@
echo file_get_contents("html/header.html"); echo file_get_contents("html/header.html");
?> ?>
<body>
<div class="table-div">
<table>
<thead>
<th scope="col">Mannschaft</th>
<th scope="col">Feuerwehr</th>
<th scope="col">Gesamtpunkte</th>
</thead>
<tbody>
<?php
load_total_score($con);
?>
</tbody>
</table>
</div>
</body>
<?php <?php
echo file_get_contents("html/footer.html"); echo file_get_contents("html/footer.html");
$con=null; $con=null;

View File

@@ -81,7 +81,18 @@ function get_teams($con) {
$stmt->execute(); $stmt->execute();
$stmt->setFetchMode(PDO::FETCH_ASSOC); $stmt->setFetchMode(PDO::FETCH_ASSOC);
return $stmt; 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); handle_pdo_exception($e);
} }
} }

View File

@@ -52,4 +52,15 @@ function load_teams_table($con) {
echo "<td>" . $row['feuerwehr'] . "</td>"; echo "<td>" . $row['feuerwehr'] . "</td>";
echo "</tr>"; echo "</tr>";
} }
}
function load_total_score($con) {
$stmt = get_total_score($con);
foreach($stmt->fetchAll() as $row) {
echo "<tr>";
echo "<td>" . $row['Mannschaftsname'] . "</td>";
echo "<td>" . $row['Feuerwehr'] . "</td>";
echo "<td>" . $row['Gesamtpunkte'] . "</td>";
echo "</tr>";
}
} }