<?php 
require("php_con.php");
if(isset($_GET['rl_product'])&&isset($_GET['rl_price'])&&isset($_GET['rl_qty'])&&isset($_GET['rl_bill_no'])){
	$rl_product=mysqli_real_escape_string($connation,$_GET['rl_product']);
	$rl_price=mysqli_real_escape_string($connation,$_GET['rl_price']);
	$rl_qty=mysqli_real_escape_string($connation,$_GET['rl_qty']);
	$rl_bill_no=mysqli_real_escape_string($connation,$_GET['rl_bill_no']);
	mysqli_query($connation,"INSERT INTO return_list (rl_id, rl_bill_no, rl_product, rl_price, rl_qty) VALUES (NULL, '$rl_bill_no', '$rl_product', '$rl_price', '$rl_qty')");
}

if(isset($_GET['rl_bill_no'])){
$total=0;
$rl_bill_no=mysqli_real_escape_string($connation,$_GET['rl_bill_no']);
$qury=mysqli_query($connation,"SELECT rl.*,pd.product_name
FROM return_list rl INNER JOIN product_details pd ON rl.rl_product=pd.product_barcode
WHERE rl.rl_bill_no='$rl_bill_no'
ORDER BY rl_id DESC");
while($resalt=mysqli_fetch_assoc($qury)){
$total+=$resalt['rl_price']*$resalt['rl_qty'];
?>
<tr>
	<td><?php echo $resalt['product_name']; ?></td>
	<td align="right"><?php echo number_format((float)$resalt['rl_price'],2); ?></td>
	<td align="right"><?php echo number_format((float)$resalt['rl_qty']); ?></td>
	<td align="right"><?php echo number_format((float)$resalt['rl_price']*$resalt['rl_qty'],2); ?></td>
</tr>
<?php } } ?>
<tr style="font-weight: bold;">
	<td colspan="3">Total Amount</td>
	<td align="right"><?php echo number_format((float)$total,2); ?></td>
</tr>