mirror of
https://github.com/janunger/rheinwerk-video-training.git
synced 2026-02-06 07:05:14 +01:00
Initiale Version
This commit is contained in:
39
Kapitel_6/Lektion_6/pdo_loesung/mediathek.php
Executable file
39
Kapitel_6/Lektion_6/pdo_loesung/mediathek.php
Executable file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
$pdo = new PDO(
|
||||
'mysql:dbname=mediathek;host=localhost',
|
||||
'root',
|
||||
'root',
|
||||
[
|
||||
PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"
|
||||
]
|
||||
);
|
||||
|
||||
$statement = $pdo->query("SELECT * FROM cds ORDER BY name ASC");
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Mediathek</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>CDs</h1>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Erscheinungsjahr</th>
|
||||
</tr>
|
||||
<?php while ($datensatz = $statement->fetch(PDO::FETCH_ASSOC)) : ?>
|
||||
<tr>
|
||||
<td><?= htmlspecialchars($datensatz['name']); ?></td>
|
||||
<td><?= htmlspecialchars($datensatz['erscheinungsjahr']); ?></td>
|
||||
</tr>
|
||||
<?php endwhile; ?>
|
||||
</table>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user