Fix: typing app menu

This commit is contained in:
2018-06-07 08:57:10 +09:00
parent 26b47536dc
commit 670d48cbc7
8 changed files with 110 additions and 103 deletions
@@ -8,7 +8,8 @@ $maestro_id = $_POST["maestro_id"];
include "./../setup/connect_db.php";
$replyJSON = get_active_typing_practice_app_list($maestro_id);
$replyJSON["Korean"] = get_active_typing_practice_app_list($maestro_id, 10);
$replyJSON["English"] = get_active_typing_practice_app_list($maestro_id, 20);
$db_conn->close();
if($replyJSON.length === 0) {
@@ -22,23 +23,24 @@ $db_conn->close();
function get_active_typing_practice_app_list($maestro_id) {
function get_active_typing_practice_app_list($maestro_id, $type) {
global $db_conn;
$query = "
SELECT A.AppID, A.AppName, A.AppType
SELECT A.AppID, A.AppName, A.KoreanName
FROM moty_app AS A
INNER JOIN moty_active_app AS AA ON A.AppType < 50 AND A.AppID = AA.AppID AND AA.MaestroID=?";
INNER JOIN moty_active_app AS AA ON A.AppType < 50 AND A.AppID = AA.AppID AND AA.MaestroID = ? AND A.AppType = ?
ORDER BY A.AppID ASC";
$stmt = $db_conn->prepare($query);
$stmt->bind_param('i', $maestro_id);
$stmt->bind_param('ii', $maestro_id, $type);
$stmt->execute();
$stmt->bind_result($app_id, $app_name, $app_type);
$stmt->bind_result($app_id, $app_name, $korean_name);
$return_array = array();
while($stmt->fetch()) {
$row_array['AppID'] = $app_id;
$row_array['AppName'] = $app_name;
$row_array['AppType'] = $app_type;
$row_array['KoreanName'] = $korean_name;
array_push($return_array, $row_array);
}
$stmt->close();