<?php
include_once 'shikanisha.kts.php';
// Check the connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT 
    products.product_id, 
    products.product_name, 
    products.company, 
    tostore.quantity, 
    tostore.stid,
    tostore.sdate
FROM 
    products
JOIN 
    tostore
ON 
    products.product_id = tostore.product_id;
";
$result = mysqli_query($conn, $sql);

// Create array to hold products
$products = array();

// Loop through results and add to array
while ($row = mysqli_fetch_assoc($result)) {
    $products[] = $row;
}

// Return array as JSON
echo json_encode($products);

// Close database connection
mysqli_close($conn);
?>