<?php   
    include('functions/userfunctions.php');
    include('includes/header.php');
    
    ?>

    <div class="py-3 bg-primary">
      <div class="container">
        <h6 clasS="text-white"> Home / Categories </h6>
      </div>
    </div>

    <div class="container py-5">
        <div class="row">
          <div class="col-md-12">

              <h1>Categories</h1>
              <hr>
              <div class="row">
                <div class="col-md-12 mb-2">
                  <div class="card shadow">
                    <div class="card-body text-center">
                        <?php
                            $categories = getAllActive("categories");
                            if(mysqli_num_rows($categories) > 0)
                            {
                                foreach($categories as $item)
                                {
                                    ?>
                                      <a href="products.php?category=<?= $item['slug']; ?>">
                                                <!--<img src="uploads/<?= $item['image']; ?>" alt="category image" class="w-100">-->
                                                  <span class="text-center px-3 active activecat"><?= $item['name']; ?></span>
                                      </a>
                                    <?php
                                }
                            }
                            else
                            {
                                echo "No data available.";
                            }
                        ?>
                    </div>
                  </div>
                </div>
              </div>  
          </div>
        </div>
    </div>
    <div class="container">
      <div class="row">
      <?php
                                        $allproducts = getProdByCategory(15);
                                       
                                        if(mysqli_num_rows($allproducts) > 0)
                                        {
                                            foreach($allproducts as $item)
                                            {
                                                ?>
                                                <div class="col-md-3 mb-2">
                                                <a href="#">
                                                    <div class="card shadow">
                                                        <div class="card-body">
                                                            
                                                            <h4 class="text-center"><?= $item['name']; ?></h4>
                                                        </div>
                                                    </div>
                                                </a>
                                                </div>
                                                    
                                                <?php
                                            }
                                        }
                                        else
                                        {
                                            echo "No data available.";
                                        }
                                    ?>
      </div>
    </div>

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