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;
}
public function showCoursePage(){
public function showCourse(){
$id = $_GET["courseId"] ?? null;
if(!$id){
header('Location: index.php');

View File

@ -10,9 +10,11 @@ class CourseModel extends Database
{
public function getCourseById(string $id){
$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
JOIN ort o ON k.ort_id = o.id
LEFT JOIN bewertungen AS b ON b.kurs_id = k.id
WHERE k.id = :id";
$sth = $pdo->prepare($sql);
$sth->execute([':id' => $id]);

View File

@ -4,15 +4,15 @@ include dirname(__DIR__).'/header.phtml';
<div class="container">
<div class="row">
<div class="col-12">
<h1><?= htmlspecialchars($kurs['titel']) ?></h1>
<p><strong>Bewertung:</strong> <?= $kurs['bewertung'] ?></p>
<div class="col-6">
<h1><?= htmlspecialchars($kurs['name']) ?></h1>
</div>
<div class="col-6">
<p><strong>Bewertung:</strong> <?= $kurs['note'] ?></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><?= 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>

View File

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