diff --git a/Controller/CourseController.php b/Controller/CourseController.php new file mode 100644 index 0000000..8d2a6f2 --- /dev/null +++ b/Controller/CourseController.php @@ -0,0 +1,35 @@ +db = new CourseModel(); + $this->view = $view; + } + + public function showCoursePage(){ + $id = $_GET["courseId"] ?? null; + if(!$id){ + header('Location: index.php'); + exit; + } + + $kurs = $this->db->getCourseById($id); + if(!$kurs){ + new \Blog\Library\ErrorMsg("Kurs nicht gefunden"); + } + + $this->view->setVars([ + "kurs" => $kurs + ]); + + } + + +} \ No newline at end of file diff --git a/Model/CourseModel.php b/Model/CourseModel.php new file mode 100644 index 0000000..79cde89 --- /dev/null +++ b/Model/CourseModel.php @@ -0,0 +1,22 @@ +linkDB(); + $sql = "SELECT k.*, o.stadt, o.strasse, o.plz + FROM kurs k + JOIN ort o ON k.ort_id = o.id + WHERE k.id = :id"; + $sth = $pdo->prepare($sql); + $sth->execute([':id' => $id]); + $result = $sth->fetch(\PDO::FETCH_ASSOC); + return $result ?? null; + } +} \ No newline at end of file diff --git a/Views/Course/showCourse.phtml b/Views/Course/showCourse.phtml new file mode 100644 index 0000000..27802a6 --- /dev/null +++ b/Views/Course/showCourse.phtml @@ -0,0 +1,20 @@ + + +
Bewertung: = $kurs['bewertung'] ?> ★
+Preis: = htmlspecialchars($kurs['preis']) ?>€
+Kursleiter: = htmlspecialchars($kurs['leiter']) ?>
+Adresse: = htmlspecialchars($kurs['strasse']) ?>, = htmlspecialchars($kurs['plz']) ?> = htmlspecialchars($kurs['stadt']) ?>
+= nl2br(htmlspecialchars($kurs['beschreibung'] ?? '')) ?>
+ ‹ Zurück zur Kursübersicht + +