-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHomeDBApi.php
More file actions
47 lines (35 loc) · 1.23 KB
/
HomeDBApi.php
File metadata and controls
47 lines (35 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
include_once("Config.php");
$conn = new mysqli($Server, $UserID, $Password, $Database);
// Total Registered users
$sql = "select count(*) from tbl_users as total";
$result = $conn->query($sql);
$row = $result->fetch_row();
$totalRegistered = $row[0];
// Total lesson completed
$sql = "select count(*) from blocklist";
$result = $conn->query($sql);
$row = $result->fetch_row();
$totalLesson = $row[0];
// Total Minute Calculation
$sql = "SELECT SUM(MINUTE(TIMEDIFF(lastUpdate,start_time))+1)
FROM tbl_user_info_history";
$result = $conn->query($sql);
$row = $result->fetch_row();
$tbl_user_info_history_time = $row[0];
$sql = "SELECT SUM(MINUTE(TIMEDIFF(lastUpdate,start_time))+1)
FROM tbl_users_history";
$result = $conn->query($sql);
$row = $result->fetch_row();
$tbl_users_history_time = $row[0];
$sql = "SELECT SUM(MINUTE(TIMEDIFF(lastUpdate,start_time))+1)
FROM tbl_reg_answers";
$result = $conn->query($sql);
$row = $result->fetch_row();
$tbl_reg_answers_time = $row[0];
$totalMinuteCompleted = $tbl_user_info_history_time
+ $tbl_users_history_time
+ $tbl_reg_answers_time;
echo json_encode(array("totalRegistered" => $totalRegistered,
"totalLesson" => $totalLesson,
"totalMinuteCompleted" => $totalMinuteCompleted));