Add: registered_player_list_page

This commit is contained in:
2018-07-02 10:41:54 +09:00
parent dc638a8e1b
commit b07daf4245
3 changed files with 195 additions and 0 deletions
@@ -0,0 +1,44 @@
<?php
header('Content-Type: application/json');
$maestroID = $_POST["maestro_id"];
/*
if(!is_numeric($enterCode)) {
send_error_code('생년월일이 숫자가 아닙니다. : '.$enterCode);
exit;
} else if(strlen($enterCode) != 6) {
send_error_code('6자리 숫자값을 정확히 입력하세요 : YYMMDD (예 : 120131) : '.$enterCode);
exit;
}
*/
include "./../setup/connect_db.php";
$result = getPlayerCount($maestroID);
if($result === null) {
send_error_message($replyJSON, "등록된 학생이 없습니다.");
// $db_conn->close();
exit;
}
$replyJSON["Count"] = $result;
$replyJSON["RESULT"] = "ok";
echo json_encode($replyJSON, JSON_UNESCAPED_UNICODE);
$db_conn->close();
function getPlayerCount($maestroID) {
global $db_conn;
$query = "SELECT COUNT(UserID) FROM moty_user WHERE MaestroID=?";
$stmt = $db_conn->prepare($query);
$stmt->bind_param('i', $maestroID);
$stmt->execute();
$stmt->bind_result($userCount);
$stmt->fetch();
$stmt->close();
return $userCount;
}
?>
@@ -0,0 +1,49 @@
<?php
header('Content-Type: application/json');
$maestroID = $_POST["maestro_id"];
$startNo = $_POST["start_no"];
$endNo = $_POST["end_no"];
include "./../setup/connect_db.php";
$replyJSON = get_player_list_page($maestroID, $startNo, $endNo);
if($replyJSON.length === 0) {
send_error_message($replyJSON, "오늘의 랭킹 기록 없음");
$db_conn->close();
exit;
}
$replyJSON["RESULT"] = "ok";
echo json_encode($replyJSON, JSON_UNESCAPED_UNICODE);
$db_conn->close();
function get_player_list_page($maestroID, $startNo, $endNo) {
global $db_conn;
$query = "
SELECT UserID, Name, EnterCode FROM moty_user
WHERE MaestroID=?
ORDER BY UserID DESC
LIMIT ?, ?;
";
$stmt = $db_conn->prepare($query);
$stmt->bind_param('iii', $maestroID, $startNo, $endNo);
$stmt->execute();
$stmt->bind_result($userID, $name, $enterCode);
$playerList = array();
while($stmt->fetch()) {
$player['UserID'] = $userID;
$player['Name'] = $name;
$player['EnterCode'] = $enterCode;
array_push($playerList, $player);
}
$return_array['PlayerList'] = $playerList;
return $return_array;
}
?>