<?php $count=0;?> <table> <?php foreach($disp as $product) { if($count==0){?> <tr> <?php } if($count%3==0 &&$count!=0){?> </tr><br><tr> <?php }?> <td><p><?php echo $product['id'];?></p></td> <td>><?php echo $product['cat_id'];?></td> <?php $count++;}?> </tr>
if(isset($_GET['displayQty'])){ $disp=$ob->getProductsByCategoryId(); }
<?php class Products extends DB{ function __construct(){ parent :: __construct(); } function getProductdata(){ $sql="SELECT * FROM tbl_products"; $data=$this->selectDataQuery($sql); return $data; } function getProductsByCategoryId(){ //$id=$_GET['displayQty']; $sql = "SELECT COUNT(*) AS total_products FROM tbl_products WHERE cat_id=".$_GET['displayQty']; $query=$this->getCntForProducts($sql); return $query; } } <pre>parent classs code
function getCntForProducts($sql,$type="assoc"){ $result=mysqli_query($this->conn,$sql); if($type=='assoc') { $disp = $this->getQurData($result); } else{ echo "error"; } return $disp; } function getQurData($result) { $i =0; $arr = array(); while($disps = mysqli_fetch_assoc($result)) { $arr[$i] = $disps; $i++; } return $arr; } }parent class code
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)