-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path_data.json.php
95 lines (69 loc) · 2.3 KB
/
_data.json.php
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<?php
header("Content-Type:", "application/json");
include './configuration/db.con.php';
$action = '';
$output = '';
$error = '';
// POST EVENT
if (isset($_POST['action'])) {
if ($_POST['action'] == 'student') {
$sql = sprintf("SELECT * FROM student ORDER BY id_student DESC");
$query = mysqli_query($con, $sql);
if (@mysqli_num_rows($query) > 0) {
while ($row = mysqli_fetch_array($query)) {
print json_encode($row);
}
} else {
print json_encode("there is no data");
}
}
if($_POST['action'] == 'r'){
$today = date('Y-m-d');
$l = $today;
$m = $today - 1;
print $today .' ' . $m;
}
if ($_POST['action'] == 'getStudent') {
$Id = mysqli_real_escape_string($con, trim(htmlentities($_POST['id'])));
$sql = mysqli_query($con, sprintf("SELECT * FROM student WHERE student_id"));
if (@mysqli_num_rows($sql) > 0) {
while ($row = mysqli_fetch_array($sql)) {
$output[] = $row;
}
} else {
$output = 'there no data';
}
print json_encode($output);
}
}
// Get method
if (isset($_GET['action'])) {
if($_GET['action'] == 'Student'){
$sql = mysqli_query($con, "SELECT * FROM student");
$row = mysqli_fetch_array($sql);
print json_encode($row);
}
if ($_GET['action'] == 'student') {
$sql = "SELECT * FROM student ORDER BY id_student DESC";
$query = mysqli_query($con, $sql);
if (@mysqli_num_rows($query) > 0) {
while ($row = mysqli_fetch_array($query)) {
print json_encode($row);
}
} else {
print json_encode("there is no data");
}
}
if ($_GET['action'] == 'getStudent') {
$Id = mysqli_real_escape_string($con, trim(htmlentities($_POST['id'])));
$sql = mysqli_query($con, sprintf("SELECT * FROM student WHERE student_id"));
if (@mysqli_num_rows($sql) > 0) {
while ($row = mysqli_fetch_array($sql)) {
$datas[] = $row;
}
} else {
$output = 'there no data';
}
print json_encode($datas);
}
}