course-seite ohne styles

This commit is contained in:
Illia Hromovoi 2025-07-11 10:41:58 +02:00
parent 07a56b31a6
commit e426926692
4 changed files with 16 additions and 17 deletions

View File

@ -13,7 +13,7 @@ class CourseController{
$this->view = $view; $this->view = $view;
} }
public function showCoursePage(){ public function showCourse(){
$id = $_GET["courseId"] ?? null; $id = $_GET["courseId"] ?? null;
if(!$id){ if(!$id){
header('Location: index.php'); header('Location: index.php');

View File

@ -10,9 +10,11 @@ class CourseModel extends Database
{ {
public function getCourseById(string $id){ public function getCourseById(string $id){
$pdo = $this->linkDB(); $pdo = $this->linkDB();
$sql = "SELECT k.*, o.stadt, o.strasse, o.plz $sql = "SELECT k.id, k.name, k.preis, k.dauer, k.rabatt, k.kategorie, k.beschreibung, k.ort_id,
o.stadt, o.strasse, o.plz, b.note, b.kommentar
FROM kurs k FROM kurs k
JOIN ort o ON k.ort_id = o.id JOIN ort o ON k.ort_id = o.id
LEFT JOIN bewertungen AS b ON b.kurs_id = k.id
WHERE k.id = :id"; WHERE k.id = :id";
$sth = $pdo->prepare($sql); $sth = $pdo->prepare($sql);
$sth->execute([':id' => $id]); $sth->execute([':id' => $id]);

View File

@ -4,15 +4,15 @@ include dirname(__DIR__).'/header.phtml';
<div class="container"> <div class="container">
<div class="row"> <div class="row">
<div class="col-12"> <div class="col-6">
<h1><?= htmlspecialchars($kurs['titel']) ?></h1> <h1><?= htmlspecialchars($kurs['name']) ?></h1>
<p><strong>Bewertung:</strong> <?= $kurs['bewertung'] ?></p> </div>
<div class="col-6">
<p><strong>Bewertung:</strong> <?= $kurs['note'] ?></p>
<p><strong>Preis:</strong> <?= htmlspecialchars($kurs['preis']) ?></p> <p><strong>Preis:</strong> <?= htmlspecialchars($kurs['preis']) ?></p>
<p><strong>Kursleiter:</strong> <?= htmlspecialchars($kurs['leiter']) ?></p>
<p><strong>Adresse:</strong> <?= htmlspecialchars($kurs['strasse']) ?>, <?= htmlspecialchars($kurs['plz']) ?> <?= htmlspecialchars($kurs['stadt']) ?></p> <p><strong>Adresse:</strong> <?= htmlspecialchars($kurs['strasse']) ?>, <?= htmlspecialchars($kurs['plz']) ?> <?= htmlspecialchars($kurs['stadt']) ?></p>
<p><?= nl2br(htmlspecialchars($kurs['beschreibung'] ?? '')) ?></p> <p><?= nl2br(htmlspecialchars($kurs['beschreibung'] ?? '')) ?></p>
<a href="index.php?controller=course&do=list"> Zurück zur Kursübersicht</a> <a href="index.php"> Zurück zur Kursübersicht</a>
</div> </div>
</div> </div>
</div> </div>

View File

@ -35,11 +35,11 @@ $location = $_GET['location'] ?? '';
</div> </div>
</div> </div>
<div class="col-8"> <div class="col-9">
<div class="course-grid row"> <div class="course-grid row">
<?php <?php
$userModel = new \Blog\Model\UserModel(); $userModel = new \Blog\Model\UserModel();
$kurse = $userModel->getAllCourses(); $kurse = $userModel->getAllCourses();
$filteredKurse = array_filter($kurse, function($kurs) use ($rating, $location) { $filteredKurse = array_filter($kurse, function($kurs) use ($rating, $location) {
if ($rating && $kurs['note'] < $rating) return false; if ($rating && $kurs['note'] < $rating) return false;
@ -58,7 +58,6 @@ $location = $_GET['location'] ?? '';
$doc = new DOMDocument('1.0', 'UTF-8'); $doc = new DOMDocument('1.0', 'UTF-8');
if (!empty($filteredKurse)) { if (!empty($filteredKurse)) {
echo '<div class="courses-view">';
foreach ($filteredKurse as $kurs) { foreach ($filteredKurse as $kurs) {
foreach ($filteredKurse as $kurs) { foreach ($filteredKurse as $kurs) {
$id = htmlspecialchars($kurs['id']); $id = htmlspecialchars($kurs['id']);
@ -69,6 +68,7 @@ $location = $_GET['location'] ?? '';
$kategorie = htmlspecialchars($kurs['kategorie'] ?? 'Keine Kategorie'); $kategorie = htmlspecialchars($kurs['kategorie'] ?? 'Keine Kategorie');
echo <<<HTML echo <<<HTML
<a style="flex: 0 0 calc(50% - 20px);" href="?controller=course&do=showCourse&courseId=$id">
<div class="course-card"> <div class="course-card">
<div class="course-image"></div> <div class="course-image"></div>
<div class="course-content"> <div class="course-content">
@ -92,7 +92,6 @@ $location = $_GET['location'] ?? '';
HTML; HTML;
} }
} }
echo '</div>';
} else { } else {
echo '<p>Keine Kurse gefunden.</p>'; echo '<p>Keine Kurse gefunden.</p>';
} }
@ -103,8 +102,6 @@ $location = $_GET['location'] ?? '';
</div> </div>
</div> </div>
</div> </div>
</div> </div>