PHP-Course/tasks/dbTest/index.php
2024-05-31 13:07:37 +02:00

58 lines
1.1 KiB
PHP

<!DOCTYPE html>
<html lang="en">
<head>
<?php include_once "../../base/meta.php" ?>
<title>Artikel</title>
</head>
<body>
<?php
include_once "../../base/settings.php";
include_once "../../base/headers.php";
Headers::html();
include_once "../../base/database.php";
$db = DB::openConnection();
$query = "
SELECT
ArtikelNr, Artikelname, Lagerbestand
FROM
Artikel
ORDER BY
ArtikelNr";
$stmt = $db->prepare($query);
$stmt->execute();
$result = $stmt->fetchAll();
DB::closeConnection($db);
?>
<div class="col">
<table class="table table-sm table-striped">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">Artikelname</th>
<th scope="col">Lagerbestand</th>
</tr>
</thead>
<tbody>
<?php
foreach ($result as $item) {
?>
<tr>
<th scope="row"><?= $item["ArtikelNr"] ?></th>
<td><?= $item["Artikelname"] ?></td>
<td><?= $item["Lagerbestand"] ?></td>
</tr>
<?php
}
?>
</table>
</div>
</body>
</html>