includes, style.css, Basis
This commit is contained in:
parent
6623a07f66
commit
e6a0acfde0
14
includes/db_connect.php
Normal file
14
includes/db_connect.php
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<?php
|
||||||
|
$host = getenv('POSTGRES_HOST');
|
||||||
|
$db = getenv('POSTGRES_DB');
|
||||||
|
$user = getenv('POSTGRES_APPUSER');
|
||||||
|
$pass = getenv('POSTGRES_APPPASSWORD');
|
||||||
|
$port = getenv('POSTGRES_PORT');
|
||||||
|
|
||||||
|
try {
|
||||||
|
$dsn = "pgsql:host=$host;port=$port;dbname=$db;";
|
||||||
|
$pdo = new PDO($dsn, $user, $pass, [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION]);
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
echo "Verbindungsfehler: " . $e->getMessage();
|
||||||
|
}
|
||||||
|
?>
|
||||||
19
index.php
19
index.php
@ -1,3 +1,20 @@
|
|||||||
<?php
|
<?php
|
||||||
echo "Hello World!";
|
require_once __DIR__ . '/includes/db_connect.php';
|
||||||
|
$system = getenv('POSTGRES_SYSTEM') ?? 'test';
|
||||||
|
|
||||||
|
$stmt = $pdo->query("SELECT vorderseite
|
||||||
|
FROM karteikarte;");
|
||||||
|
$karteikarten = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
?>
|
?>
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<link rel="stylesheet" href="style.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<?php foreach ($karteikarten as $y): ?>
|
||||||
|
<p>Vorderseite: <?= $y['vorderseite'] ?></p>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Loading…
Reference in New Issue
Block a user