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

require_once "../config.php";

$conn = connect_db();

$res = array();

if ($conn->connect_error) {
	die('Connection failed: ' . $conn->connect_error);
} else {
	$sql = "
		SELECT liangshu, ming, gejue1, gejue2, gejue, zhujie 
		FROM `chenggu_result`
	";
	$result = $conn->query($sql);

	if ($result->num_rows > 0) {
		while ($row = $result->fetch_assoc()) {
			$temp = array(
				"liangshu" => $row["liangshu"],
				"ming" => $row['ming'],
				"gejue1" => $row['gejue1'],
				"gejue2" => $row['gejue2'],
				"gejue" => $row['gejue'],
				"zhujie" => $row['zhujie']
			);

			array_push($res, $temp);
		}
	}
}

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