-
Notifications
You must be signed in to change notification settings - Fork 2
/
qqq15.php
41 lines (33 loc) · 1.12 KB
/
qqq15.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
<?php
ini_set("max_execution_time",1000000000);
$set_charset = 'export LANG=ko_KR.UTF-8;';
set_time_limit(1000000000);
$name=$_GET['name'];
$begin=$_GET['begin'];
$end=$_GET['end'];
$date=$_GET['date'];
DEFINE ('DB_USER','root');
DEFINE ('DB_PASSWORD','caucse1234');
DEFINE ('DB_HOST','localhost');
DEFINE ('DB_NAME','virus');
$dbc=@mysqli_connect(DB_HOST,DB_USER,DB_PASSWORD,DB_NAME) OR die('Could not to connect to Mysql:'.mysqli_connect_error());
header("content-type:text/json;charset=utf-8");
$db_selected=@mysqli_connect(DB_HOST,DB_USER,DB_PASSWORD,DB_NAME) OR die('Could not to connect to Mysql:'.mysqli_connect_error());
if (!$db_selected)
{
die ("Can\'t use " );
}
$sql = 'SELECT weather.qiwen FROM weather,test where weather.KID=test.KID and test.city= "'.$name.'" and weather.date>="'.$begin.'" AND weather.date < "'.$end.'"';
$result = mysqli_query($dbc,$sql);
$arr=mysqli_fetch_all($result);
$arrayavg= array();
for ($i=0;$i<count($arr)/24;$i++){
$sum=0;
for ($j=0;$j<24;$j++){
$sum=$sum+$arr[$j+($i*24)][0];
}
$arrayavg[]= $sum/24;
};
$data = json_encode($arrayavg);
echo $data;
?>