<?php
include("admin/opendb.php");

if (isset($_GET['slug'])) {
    $slug = mysqli_real_escape_string($conn, $_GET['slug']);
    $sql = "SELECT * FROM course WHERE slug = '$slug' LIMIT 1";
    $result = mysqli_query($conn, $sql);
    $course = mysqli_fetch_assoc($result);

    if (!$course) {
        die("Course not found");
    }
} else {
    die("Invalid request");
}

  $pageTitle = $course['title'] . " - PSN MENTOR";
  $activeMenu = "course_details";
  include ("parts/header.php");
?>

  <main class="main">
    <!-- About Us Section -->
    <section id="about" class="about section">
      <div class="container">
        <div class="row gy-4">
          <div class="col-lg-6 order-1 order-lg-2" data-aos="fade-up" data-aos-delay="100" style="display: flex;">
            <img src="/admin/uploads/<?= $course['image'] ?>" class="img-fluid" alt="PSNMentor brand strategy workshop" style="object-fit: cover; border-radius: 10px;">
          </div>

          <div class="col-lg-6 order-2 order-lg-1 content" data-aos="fade-up" data-aos-delay="200">
            <h3><?= $course['title'] ?></h3>
            <div class="description pb-4" style="white-space: pre-line;">
                <?= $course['description'] ?>
            </div>
            <a href="/enquiry" class="read-more">
              <span>Apply Now</span><i class="bi bi-arrow-right"></i>
            </a>
          </div>
        </div>
      </div>
    </section>
    <!-- /About Us Section -->
  </main>

  <?php
  include("parts/footer.php");
  ?>