<?php 
session_start();
include 'db_connection.php';



if(isset($_POST['category'])){
$category = $_POST['category'];
 $productlist = mysqli_query($conn, "SELECT * FROM mobileproducts WHERE status='1' AND category='$category'"); 
if ($productlist->num_rows > 0) {
    while($row = $productlist->fetch_assoc()) { 
        $prid = $row['prid'];
		$itemcode = $row['itemcode'];
        $panem = $row['proname'];
		$sellprice = number_format((float)$row['sellprice'], 2);
            echo '<div class="product col-lg-3" onclick="addNewProductById('.$prid.');" style="cursor:pointer;">
                <div class="productwrap">
						<h6 style="text-align: center;background: #08a306;font-size:10px;color:#ffffff;padding:4px;margin-bottom:0rem;">'.$itemcode.'</h6>
						<h6 style="text-align: center;background: #000000;font-size:11px;color:#ffffff;padding:4px;margin-bottom:0rem;">'.$panem.'</h6>
						<img src="assets/img/empty.png"/ width="100%">
						<p style="text-align: center;background: #08a306;font-size:12px;color:#ffffff;padding:4px;">Rs.'.$sellprice.'</p>
                </div>
            </div>';
  }
}

}

if(isset($_POST['subcat'])){
    $category = $_POST['subcat'];
     $productlist = mysqli_query($conn, "SELECT * FROM mobileproducts WHERE status='1' AND subcategory='$category'"); 
    if ($productlist->num_rows > 0) {
        while($row = $productlist->fetch_assoc()) { 
            $prid = $row['prid'];
			$itemcode = $row['itemcode'];
            $panem = $row['proname'];
			$sellprice = number_format((float)$row['sellprice'], 2);
                echo '<div class="product col-lg-3" onclick="addNewProductById('.$prid.');" style="cursor:pointer;">
                    <div class="productwrap">
						<h6 style="text-align: center;background: #08a306;font-size:10px;color:#ffffff;padding:4px;margin-bottom:0rem;">'.$itemcode.'</h6>
                        <h6 style="text-align: center;background: #000000;font-size:11px;color:#ffffff;padding:4px;margin-bottom:0rem;">'.$panem.'</h6>
						<img src="assets/img/empty.png"/ width="100%">
						<p style="text-align: center;background: #08a306;font-size:12px;color:#ffffff;padding:4px;">Rs.'.$sellprice.'</p>
                    </div>
                </div>';
      }
    }
    
    }



    if(isset($_POST['category2'])){
        $category = $_POST['category2'];
        $subcategorylist = mysqli_query($conn, "SELECT * FROM mobilesubcategory WHERE category='$category' AND status='1'"); 
        if ($subcategorylist->num_rows > 0) {
            echo "<div class='row'>";
            while($row = $subcategorylist->fetch_assoc()) { 
                $sbid = $row['sbid'];
                $subname = $row['subname'];
                    echo '<div class="col-lg-2">
                                <a onclick="subcatproductload('.$sbid.');" style="cursor:pointer;">
                                    <div class="item">                   
                                        <h6 style="text-align: center;background: #000000;font-size:10px;color:#ffffff;padding:5px;">'.$subname.'</h6>
                                    </div>
                                </a>
                    </div>';
          }
          echo "</div>";
        }
        
        }

?>    