1
0

Erster Commit

This commit is contained in:
Anna Christina Naß
2025-07-07 16:25:22 +02:00
parent 3b9e7bb194
commit ce5baaac35
23 changed files with 671 additions and 2 deletions

27
index.php Normal file
View File

@@ -0,0 +1,27 @@
<?php
require_once 'Twig/autoload.php';
require_once 'config.php';
require_once 'functions.php';
use Twig\Environment;
use Twig\Loader\FilesystemLoader;
$loader = new FilesystemLoader(__DIR__ . '/templates');
$twig = new Environment($loader);
// --------------
$dbconn = pg_connect($dbconnstring)
or die(twig_error($twig, 'Kann Verbindung zur Datenbank nicht herstellen.'));
$query = "SELECT id,timestamp FROM tests ORDER BY timestamp DESC";
$result = pg_query($dbconn, $query)
or die(twig_error($twig, 'Datenbankfehler: ' . pg_last_error()));
$tests = pg_fetch_all($result);
pg_close($dbconn);
echo $twig->render('index.html.twig', [ 'tests' => $tests ]);
?>