<!doctype html>
<html lang="en">
  <head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <!-- Bootstrap CSS -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">

    <title>Welcome to iDiscuss - Code Forum</title>
  </head>
  <body>

 <?php 
  include '_header.php';
   ?> 

<?php
  include '_dbconnect.php';
?>

<!-- Slider starts here -->
<div id="carouselExampleIndicators" class="carousel slide" data-ride="carousel">
   <ol class="carousel-indicators">
    <li data-bs-target="#carouselExampleIndicators" data-slide-to="0" class="active" ></li>
    <li data-bs-target="#carouselExampleIndicators" data-slide-to="1"></li>
    <li data-bs-target="#carouselExampleIndicators" data-bs-slide-to="2"></li>
  </ol>
  <div class="carousel-inner">
    <div class="carousel-item active">
      <img src="/login/forum/unplash.jpg" class="d-block" height="600" width="900">
    </div>
    <div class="carousel-item">
      <img src="clark.jpg" class="d-block" height="600" width="900">
    </div>
    <div class="carousel-item">
      <img src="sun.jpg" class="d-block" height="600" width="900">
    </div>
  </div>
  <button class="carousel-control-prev" type="button" data-bs-target="#carouselExampleControls" data-bs-slide="prev">
    <span class="carousel-control-prev-icon" aria-hidden="true"></span>
    <span class="visually-hidden">Previous</span>
  </button>
  <button class="carousel-control-next" type="button" data-bs-target="#carouselExampleControls" data-bs-slide="next">
    <span class="carousel-control-next-icon" aria-hidden="true"></span>
    <span class="visually-hidden">Next</span>
  </button>
</div><br>

<!-- Category container starts here  -->
<div class="container my-3">
<h2 class="text-center my-3">iDiscuss - Browser Categories</h2>
<div class="row my-3">

<!-- Fetch all the categories and use a for loop to iterate through categories -->

 <?php 
  $sql = "SELECT * FROM `categories`";
  $result = mysqli_query($conn, $sql);
  while($row = mysqli_fetch_assoc($result)){
// echo $row['category_id'];
 // echo $row['category_name'];
 $cat = $row['category_name'];
 $desc = $row['category_description'];
 echo '<div class="col-md-4 my-2">
    <div class="card" style="width: 18rem;">
       <img src="sun.jpg' .$cat. '" class="card-img-top" height="150"> 
      <div class="card-body">
        <h4 class="card-title"><a href="/threads">' .$cat. ' </a></h4>
        <p class="card-text">' . substr($desc,0,90).' ...</p>
        <a href="#" class="btn btn-primary">View Threads</a>
      </div>
    </div>
 </div>';
}
?>
 
</div>
</div>

<?php include '_footer.php'; ?>

    <!-- Optional JavaScript; choose one of the two!-->

    <!-- Option 1: Bootstrap Bundle with Popper -->
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>

    <!-- Option 2: Separate Popper and Bootstrap JS -->
    <!--
    <script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.9.2/dist/umd/popper.min.js" integrity="sha384-IQsoLXl5PILFhosVNubq5LC7Qb9DXgDA9i+tQ8Zj3iwWAwPtgFTxbJ8NT4GN1R8p" crossorigin="anonymous"></script>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.min.js" integrity="sha384-cVKIPhGWiC2Al4u+LWgxfKTRIcfu0JTxR+EQDz/bgldoEyl4H0zUF0QKbrJ0EcQF" crossorigin="anonymous"></script>
    -->
  </body>
</html>
