-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdata.php
60 lines (45 loc) · 1.3 KB
/
data.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
<?php
//this script select the data from the database and encode it into JSON
header('Content-Type: application/json');
$category = $_COOKIE["category"];
$del = ' 00:00:00';
$date = '2015-08-01';
$fDate = $_COOKIE["fDate"].$del;
$lDate = $_COOKIE["lDate"].$del;
$dr = $_COOKIE["dr"];
//echo $_POST['category'];
if($dr == '5')
{
//filtering to data set. high number of records may crash the browser
$sqlQuery = "select time,$category from info where time>='$fDate' AND time<'$lDate' limit 5";
}
if($dr == '10')
{
$sqlQuery = "select time,$category from info where time>='$fDate' AND time<'$lDate' limit 10";
}
if($dr == '100')
{
$sqlQuery = "select time,$category from info where time>='$fDate' AND time<'$lDate' limit 100";
}
if($dr == '200')
{
$sqlQuery = "select time,$category from info where time>='$fDate' AND time<'$lDate' limit 200";
}
if($dr == 'ALL')
{
$sqlQuery = "select time,$category from info where time>='$fDate' AND time<'$lDate'";
}
if ($category== 'all')
{
$sqlQuery = "select * from info where time>='$fDate' AND time<'$lDate' limit 100";
}
$conn = mysqli_connect("localhost","root","","ac");
$result = mysqli_query($conn,$sqlQuery);
$data = array();
foreach ($result as $row) {
$data[] = $row;
}
mysqli_close($conn);
echo json_encode($data);
//header("Location:chart.php");
?>