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

$sql = "SELECT * FROM course";
$result = mysqli_query($conn,$sql);
$courses = mysqli_fetch_all($result, MYSQLI_ASSOC);

?>

<?php
  $pageTitle = "Courses - PSN MENTOR";
  $activeMenu = "courses";
  include("parts/header.php");
?>

  <main class="main">
    <!-- Courses Section -->
    <section id="courses" class="courses section">
      <div class="container">
        <div class="row">
          <?php foreach($courses as $row) { ?>
          <div class="col-lg-4 col-md-6 d-flex align-items-stretch" data-aos="zoom-in" data-aos-delay="100">
            <div class="course-item">
              <img src="admin/uploads/<?= $row['image'] ?>" class="img-fluid" alt="PSNMentor brand strategy workshop">
              <div class="course-content">
                <div class="d-flex justify-content-between align-items-center mb-3">
                  <p class="category"><?= $row['category'] ?></p>
                  
                </div>
                <h3><?= $row['title'] ?></h3>
                <p class="description"><?= substr(strip_tags($row['description']), 0, 100) ?>...</p>
                <a href="/courses/<?= $row['slug'] ?>" class="read-more">
                  <span>Read More</span><i class="bi bi-arrow-right"></i>
                </a>
              </div>
            </div>
          </div> 
          <?php } ?>
        </div>
      </div>
    </section>
  </main>

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