<?php 
require("php_con.php");
?>
<table class="table table-sm mt-2">
  <tbody>
    <tr class="table-active">
      <td>Action</td>
      <td>Item</td>
      <td align="right">Rate</td>
      <td align="right">Qty</td>
      <td align="right">Amount</td>
    </tr>
<?php
if(isset($_GET['sale_details_billid'])){
$sale_details_billid=mysqli_real_escape_string($connation,$_GET['sale_details_billid']);
$query=mysqli_query($connation,"SELECT sl.*,pd.product_name
FROM sale_details sd RIGHT JOIN sale_list sl ON sd.sale_details_billid=sl.sale_billid
INNER JOIN product_details pd ON sl.sale_barcode=pd.product_barcode
WHERE sd.sale_details_billid='$sale_details_billid'");
if(mysqli_num_rows($query)>0){}
else{
echo "<div class='alert alert-danger text-center'>Sorry! Bill not found, try again.</div>";
}
while($resalt=mysqli_fetch_assoc($query)){
?>
    <tr>
      <td><button type="button" class="btn btn-sm btn-danger" onClick="fill_details('<?php echo $resalt['sale_barcode']; ?>','<?php echo $resalt['product_name']; ?>','<?php echo $resalt['sale_saleprice']; ?>','<?php echo $resalt['sale_qty']; ?>');">Return</button></td>
      <td><?php echo $resalt['product_name']; ?></td>
      <td align="right"><?php echo number_format((float)$resalt['sale_saleprice'],2); ?></td>
      <td align="right"><?php echo number_format((float)$resalt['sale_qty']); ?></td>
      <td align="right"><?php echo number_format((float)$resalt['sale_saleprice']*$resalt['sale_qty'],2); ?></td>
    </tr>
<?php } } ?>
  </tbody>
</table>