  

  ?>
  <section class="new-arrival">
          <?php
            $per_page = 4;
            if (isset($_GET['page2'])) {
              //echo "lets go";
              $page2 = $_GET['page2'];
            }else {
              //echo "wait for a minute";
              $page2 = "";
            }if ($page2=='' || $page2==1) {
              $page1 = 0;
            }else {
              $page1 = ($page2 * $per_page) - $per_page;
            }



            $sql1 = "SELECT * FROM products";
            $res1 = mysqli_query($conn, $sql1);
            $count1= mysqli_num_rows($res1);
            $count1 = ceil($count1 / $per_page);
            //echo $count3;
             ?>
        <!-- heading -->
        <div class="arrival-heading">
          <strong>Related Products</strong>
          <p>See Products Related To Your Search</p>
        </div>
        <div class="product-container">
          <!-- pproduct box-->
          <?php
            $sql = "SELECT * FROM products LIMIT $page1, $per_page";
            $res = mysqli_query($conn, $sql);
            $count= mysqli_num_rows($res);
            if ($count>0) {
              while ($row = mysqli_fetch_assoc($res)) {
                // code...
                $id = $row['id'];
                $title = $row['title'];
                $image_name = $row['image_name'];
                $description = $row['description'];
                $featured = $row['featured'];
                $active = $row['active'];
                $size = $row['size'];
                $price = $row['price'];
                $qty = $row['qty'];
                ?>
          <form action="item-description1.php" method="post" enctype="multipart/form-data">
            <div class="product-box">

              <div class="product-img">
                  <!-- cart-->
                  <!-- cart -->
               
                <!-- <input type="submit" name="submit" value="cart" class="add-cart"> -->

                <?php
                if ($image_name) {
                  //img is available
                  ?>
                  <img src="<?php echo SITEURL; ?>images/products/<?php echo $image_name; ?>" width="100px" >
                  <?php
                }else {
                  //img is not available
                  echo  "<div class='error'>Img is not Added</div>";
                }

                 ?>
              </div>
              <div class="product-details">
                <a href="javascript:void(0);" class="p-name"><?php echo $title?></a>
                <span class="p-price">$<?php echo $price?></span>
                <button type="submit" name="submit" class="add-cart">
                   VIEW PRODUCT
                </button>
              </div>
               <input type="hidden" name="qty" value="<?php echo $qty?>">
              <input type="hidden" name="id" value="<?php echo $id?>">
              <input type="hidden" name="title" value="<?php echo $title?>">
              <input type="hidden" name="image_name" value="<?php echo $image_name?>">
              <input type="hidden" name="price" value="<?php echo $price?>">
              <input type="hidden" name="size" value="<?php echo $size?>">
              <input type="hidden" name="description" value="<?php echo $description?>">
              <input type="hidden" name="active" value="<?php echo $active?>">
              <input type="hidden" name="featured" value="<?php echo $featured?>">

            </div>
            <!-- pproduct box -->
          </form>

          <?php
        }
      }else {
        echo 'No clothes Added';
      }
      ?>

        </div>
        <ul class="pager">
            <?php
            for ($i=1; $i <=$count1 ; $i++) {
              if ($i == $page2) {
                  echo "<li><a class='active_link' href='catproducts.php?page2=$i'>$i</a></li>";
              }else {
                echo "<li><a href='catproducts.php?page2=$i'>$i</a></li>";
              }

            }

             ?>

           </ul>


      </section>
