<?php
// server.php

// Include the database connection file
require_once 'shikanisha.kts.php';



// Check connection
if (!$conn) {
    die("Connection failed: " . mysqli_connect_error());
}

// Fetch data from the database where exp_date is less than 3 months from the current date
$sql = "SELECT `product_id`, `product_name`, `shop_quantity`, `exp` FROM `products` WHERE `category1` = 'Pharmacy' AND `exp` < DATE_ADD(NOW(), INTERVAL 3 MONTH)";

$result = mysqli_query($conn, $sql);

// Store the result in an array
$data = array();
while ($row = mysqli_fetch_assoc($result)) {
    $data[] = $row;
}

// Close the database connection
mysqli_close($conn);

// Return the data as JSON
echo json_encode($data);
?>
