added notes page

This commit is contained in:
Felix Ivo 2025-06-13 08:06:38 +02:00
parent c7882bc1a1
commit 3862b68d9f
3 changed files with 73 additions and 0 deletions

View File

@ -0,0 +1,27 @@
<?php
namespace ppa\Controller;
use ppa\Model\NotesModel;
use ppa\Library\View;
class NotesController
{
private $notesModel;
protected $view;
public function __construct($view)
{
$this->notesModel = new NotesModel();
$this->view = $view;
}
public function showNotes()
{
$this->view->setVars([
"notes" => $this->notesModel->selectNotes()
]);
}
}

29
Model/NotesModel.php Normal file
View File

@ -0,0 +1,29 @@
<?php
namespace ppa\Model;
use ppa\Model\ParticipantModel;
class NotesModel extends Database
{
public function selectNotes()
{
$sortBy = 'updated_at';
$sortOrder = 'DESC';
$sql = "SELECT id, title, content, created_at, updated_at
FROM notes
WHERE user_id = 2
ORDER BY updated_at DESC";
$pdo = $this->linkDB();
try {
$res = $pdo->query($sql);
} catch (\PDOException $e) {
new \ppa\Library\ErrorMsg("Ihre Anfrage konnte nicht verarbeitet werden", $e);
die;
}
return $res->fetchAll(\PDO::FETCH_ASSOC);
}
}

View File

@ -0,0 +1,17 @@
<?php include dirname(__DIR__).'/header.phtml'; ?>
<h2>Notes</h2>
<div class="container">
<?php
foreach($notes as $n) {
echo '<div class="item-4-12">';
echo '<h3>' . $n["title"] . '</h3>'
. '<p>' . $n["content"] . '</p>';
echo '</div>';
}
?>
</div>
<?php include dirname(__DIR__).'/footer.phtml'; ?>