Click here to Skip to main content
15,917,793 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
<?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>


What I have tried:

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
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900