Your IP : 216.73.216.93


Current Path : /home/users/unlimited/www/nigeria.codeskitter.site/
Upload File :
Current File : /home/users/unlimited/www/nigeria.codeskitter.site/my-courses.php

<?php
include 'includes/config.php';
include 'includes/header.php';

if(!isset($_SESSION['user_id'])) {
    header("Location: login.php");
    exit();
}

// Get user's enrolled courses
$enrolled_sql = "SELECT c.*, e.enrolled_at, cat.name as category_name 
                 FROM enrollments e 
                 JOIN courses c ON e.course_id = c.id 
                 LEFT JOIN categories cat ON c.category_id = cat.id 
                 WHERE e.user_id = ? 
                 ORDER BY e.enrolled_at DESC";
$enrolled_stmt = $conn->prepare($enrolled_sql);
$enrolled_stmt->bind_param("i", $_SESSION['user_id']);
$enrolled_stmt->execute();
$enrolled_courses = $enrolled_stmt->get_result();
?>

<div class="container py-5">
    <h1 class="text-center mb-5">My Courses</h1>
    
    <?php if($enrolled_courses->num_rows > 0): ?>
        <div class="row">
            <?php while($course = $enrolled_courses->fetch_assoc()): 
                $image_path = getCourseImagePath($course['image']);
            ?>
            <div class="col-lg-4 col-md-6 mb-4">
                <div class="card course-card h-100">
                    <div class="enrolled-badge">Enrolled</div>
                    <img src="<?php echo $image_path; ?>" class="card-img-top" alt="<?php echo htmlspecialchars($course['title']); ?>"
                         onerror="this.onerror=null; this.src='assets/images/course-placeholder.jpg';"
                         style="height: 200px; object-fit: cover;">
                    <div class="card-body">
                        <h5 class="card-title"><?php echo htmlspecialchars($course['title']); ?></h5>
                        <p class="card-text text-muted"><?php echo substr(htmlspecialchars($course['description']), 0, 100); ?>...</p>
                        <div class="course-meta mb-2">
                            <small class="text-muted">
                                <i class="bi bi-folder me-1"></i><?php echo htmlspecialchars($course['category_name']); ?>
                            </small>
                            <br>
                            <small class="text-muted">
                                <i class="bi bi-calendar me-1"></i>Enrolled: <?php echo date('M j, Y', strtotime($course['enrolled_at'])); ?>
                            </small>
                        </div>
                    </div>
                    <div class="card-footer bg-transparent">
                        <div class="d-grid gap-2">
                            <a href="course-content.php?id=<?php echo $course['id']; ?>" class="btn btn-primary btn-sm">
                                <i class="bi bi-play-circle me-1"></i>Continue Learning
                            </a>
                        </div>
                    </div>
                </div>
            </div>
            <?php endwhile; ?>
        </div>
    <?php else: ?>
        <div class="text-center py-5">
            <i class="bi bi-book fs-1 text-muted mb-3"></i>
            <h4 class="text-muted">No Courses Enrolled Yet</h4>
            <p class="text-muted">Start your learning journey by enrolling in a course.</p>
            <a href="courses.php" class="btn btn-primary">Browse Courses</a>
        </div>
    <?php endif; ?>
</div>

<style>
.enrolled-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: #198754;
    color: white;
    padding: 5px 10px;
    border-radius: 15px;
    font-size: 0.8rem;
    font-weight: 600;
    z-index: 1;
}
</style>

<?php include 'includes/footer.php'; ?>