<?php
	include'connection.php';
	$catName = $_GET['catName'];
	$sl=0;
	$quGetProduct="select * from product where Category='$catName'";
	$reGetProduct=mysqli_query($con,$quGetProduct);
	
		echo "<table cellpadding='20' border='2'> 
			<tr>
				<th>Sl.</th>
				<th>Product Id</th>
				<th>Product Code</th>
				<th>Brand Name</th>
				<th>Product Name</th>
				<th>Product Size</th>
				<th>Amount</th>
				<th>Qty.</th>
				<th>Total Amount</th>
				<th>Discount</th>
				<th>Net Amount</th>
				<th>Add To Cart</th>
			</tr>";
	while($dataGetproduct=mysqli_fetch_array($reGetProduct))
	{
		$sl=$sl+1;
		$PCode = $dataGetproduct['PCode'];
		$quGetAdded="SELECT * FROM cart WHERE PCode='".$PCode."'";
		$reGetAdded=mysqli_query($con,$quGetAdded);
		$rowGetAdded=mysqli_num_rows($reGetAdded);
		if($rowGetAdded>=1)
		{
			$sttsChkd = "show";
			$sttsNotChkd = "hide";
		}
		else
		{
			$sttsChkd = "hide";
			$sttsNotChkd = "show";
		}
		echo "<tr>
				<td>".$sl."</td>
				<td>".$dataGetproduct['Id']."</td>
				<td><input type='number' class='PCode' id='PCode".$sl."' value='".$dataGetproduct['PCode']."'>".$dataGetproduct['PCode']."</td>
				<td>".$dataGetproduct['Brand']."</td>
				<td>".$dataGetproduct['Name']."</td>
				<td>".$dataGetproduct['Size']."</td>
				<td><input type='number' class='amount' id='amount".$sl."' value='".$dataGetproduct['Rate']."'>".$dataGetproduct['Rate']."</td>
				<td><input type='number' class='quantity' id='quantity".$sl."' onkeyup='purchase(".$sl.")'></td>
				<td><p id='TotalAmount".$sl."'></p></td>
				<td><input type='number' class='discount' id='discount".$sl."' value='".$dataGetproduct['Discount']."'></p>".$dataGetproduct['Discount']."%</td>
				<td><p id='NetAmount".$sl."'></p></td>
				<td>
					<i class='fa fa-check-square ".$sttsChkd."' id='Del".$sl."' onclick='delCart(".$sl.")'></i>
					<i class='far fa-square ".$sttsNotChkd."' id='Add".$sl."' onclick='addCart(".$sl.")'></i>
				</td>
				
			</tr>";
		
	}
	echo "</table>";

?>