<?php
include('connection.php');

if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}

$selectedOrigin = $_POST['origin'];

$sql = "SELECT salt FROM product WHERE origin = ? AND status='1'";
$stmt = $conn->prepare($sql);
$stmt->bind_param("s", $selectedOrigin);
$stmt->execute();

$result = $stmt->get_result();
$options = '<option value="">Select Salt</option>';

while ($row = $result->fetch_assoc()) {
    $options .= '<option value="' . $row['salt'] . '">' . $row['salt'] . '</option>';
}

$response = array("options" => $options);
echo json_encode($response);

$stmt->close();
$conn->close();
?>
