53 lines
2.1 KiB
PHP
53 lines
2.1 KiB
PHP
<?php
|
|
require_once 'templates/header.php';
|
|
|
|
if (!isset($_SESSION['user_id'])) {
|
|
header('Location: login.php');
|
|
exit();
|
|
}
|
|
|
|
require_once 'db/config.php';
|
|
$pdo = db();
|
|
$stmt = $pdo->query('SELECT * FROM courses ORDER BY created_at DESC');
|
|
$courses = $stmt->fetchAll();
|
|
|
|
?>
|
|
|
|
<div class="container">
|
|
<h1 class="text-center mb-4">Courses</h1>
|
|
|
|
<?php if (empty($courses)): ?>
|
|
<div class="alert alert-info">No courses available yet.</div>
|
|
<?php else: ?>
|
|
<div class="row">
|
|
<?php foreach ($courses as $course): ?>
|
|
<div class="col-md-4 mb-4">
|
|
<div class="card h-100">
|
|
<div class="card-body d-flex flex-column">
|
|
<h5 class="card-title"><?php echo htmlspecialchars($course['title']); ?></h5>
|
|
<div>
|
|
<span class="badge bg-info me-2"><?php echo ucfirst(htmlspecialchars($course['type'])); ?></span>
|
|
<?php if ($course['tier'] === 'premium'): ?>
|
|
<span class="badge bg-success">Premium</span>
|
|
<?php else: ?>
|
|
<span class="badge bg-secondary">Free</span>
|
|
<?php endif; ?>
|
|
</div>
|
|
<p class="card-text mt-2 flex-grow-1"><?php echo htmlspecialchars($course['description']); ?></p>
|
|
|
|
<div class="mt-auto">
|
|
<?php if ($course['tier'] === 'premium' && !empty($course['price'])): ?>
|
|
<p class="fw-bold fs-5 mb-2">$<?php echo htmlspecialchars($course['price']); ?></p>
|
|
<?php endif; ?>
|
|
<a href="#" class="btn btn-primary">View Course</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
|
|
<?php require_once 'templates/footer.php'; ?>
|