<?php
header('Access-Control-Allow-Origin: *');
header("Access-Control-Allow-Methods: POST");

require_once "../config.php";

$json = file_get_contents("php://input");
$data = json_decode($json);

$yue = $data->yue;

$conn = connect_db();

$res = array();

if ($conn->connect_error) {
	die('Connection failed: ' . $conn->connect_error);
} else {
	$sql = "
		SELECT ID 
		FROM `liangshu_yue` 
		WHERE yue = '" . $yue . "月'
		LIMIT 1
	";
	$result = $conn->query($sql);

	if ($result->num_rows > 0) {
		while ($row = $result->fetch_assoc()) {
			$res["ID"] = $row["ID"];
		}
	}
}

$conn->close();
echo json_encode($res);
