<?php include './db.php';?>
<?php 
 $connection = new mysqli($dbhost,$dbusername,$dbpassword,$dbname); 
if($connection->connect_error){
  die("error while connecting database".$connection->connect_error);
}
$getSales="
    SELECT 
        m.Invoice,
        s.ID AS orderid,
        m.Date,
        m.OrderType,
        p.Name AS Product_name,
        s.AmountPerPC AS Price,
        s.Quantity,
        s.Amount
    FROM invoice m
    INNER JOIN orders s ON m.Invoice = s.Invoice
    INNER JOIN product p ON s.Product = p.ID
    WHERE m.Order_Status = 'Confirmed'
";
$result=$connection->query($getSales);
$data=[];
while($row=$result->fetch_assoc()){
    $data[]=$row;
}
echo json_encode($data);
?>