show teams table and terminate db connection

This commit is contained in:
2022-06-08 12:30:53 +02:00
parent c701d808e5
commit 42cd6956b9
7 changed files with 55 additions and 4 deletions

View File

@@ -12,4 +12,7 @@
<h1><span>Punktesystem Kreispokalwettbewerb Altdorf</span></h1> <h1><span>Punktesystem Kreispokalwettbewerb Altdorf</span></h1>
<p>test</p> <p>test</p>
</body> </body>
<?php echo file_get_contents("html/footer.html"); ?> <?php
$con = null;
echo file_get_contents("html/footer.html");
?>

View File

@@ -21,6 +21,7 @@
echo "Gib bitte gültige Daten ein!"; echo "Gib bitte gültige Daten ein!";
} }
} }
$con = null;
?> ?>
<!DOCTYPE html> <!DOCTYPE html>

View File

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

View File

@@ -26,4 +26,7 @@
</div> </div>
</body> </body>
<?php echo file_get_contents("html/footer.html"); ?> <?php
echo file_get_contents("html/footer.html");
$con = null;
?>

View File

@@ -7,4 +7,7 @@
echo file_get_contents("html/header.html"); echo file_get_contents("html/header.html");
?> ?>
<?php echo file_get_contents("html/footer.html"); ?> <?php
echo file_get_contents("html/footer.html");
$con=null;
?>

View File

@@ -74,3 +74,14 @@ function get_stations($con) {
handle_pdo_exceptio($e); handle_pdo_exceptio($e);
} }
} }
function get_teams($con) {
try {
$stmt = $con->prepare("SELECT name, feuerwehr FROM Mannschaft");
$stmt->execute();
$stmt->setFetchMode(PDO::FETCH_ASSOC);
return $stmt;
} catch(PDOExeption $e) {
handle_pdo_exception($e);
}
}

View File

@@ -43,3 +43,13 @@ function load_stations_table($con) {
echo "</tr>"; echo "</tr>";
} }
} }
function load_teams_table($con) {
$stmt = get_teams($con);
foreach($stmt->fetchAll() as $row) {
echo "<tr>";
echo "<td>" . $row['name'] . "</td>";
echo "<td>" . $row['feuerwehr'] . "</td>";
echo "</tr>";
}
}