<?php
header("Content-Type: application/json");

$maestro_id = $_POST["MaestroID"];
$player_id = $_POST["PlayerID"];
// echo $maestro_id." / ".$player_id;

include "./../lib/send_reply_json.php";
include "./../setup/connect_db.php";

// get license_time data
$score_list = get_score_list($maestro_id, $player_id);

// send license_time data back to client
set_data("scoreList", $score_list);
send_result_success();
exit;



function get_score_list($maestro_id, $player_id) {
	global $db_conn;

	$query = "
		SELECT SubjectName, Score, ScoreDateTime
		FROM license_score
		WHERE MaestroID = ? AND PlayerID = ?
		ORDER BY ScoreDateTime DESC
	";
	$stmt = $db_conn->prepare($query);
	$stmt->bind_param("ii", $maestro_id, $player_id);
	$stmt->execute();
	$stmt->bind_result($subject_name, $score, $score_date_time);

	$score_list = array();
	while($stmt->fetch()) {
		$score_data["SubjectName"] = $subject_name;
		$score_data["Score"] = $score;
		$score_data["ScoreDateTime"] = $score_date_time;
	    array_push($score_list, $score_data);
	}
	$stmt->close();

	return $score_list;
}

?>