source: branches/testFACT++branch/www/schedule/load.php@ 20115

Last change on this file since 20115 was 18045, checked in by Daniela Dorner, 10 years ago
changed column names of the table Measurement for consistency when switching to real DB
File size: 1.9 KB
Line 
1<?php
2
3
4if (!isset($_POST['n']))
5 return header('HTTP/1.0 400 Syntax error.');
6
7// ================================================================
8// Database interaction
9// ================================================================
10
11function query($query)
12{
13 $sql = mysql_query($query);
14 if (!$sql)
15 die(mysql_error());
16
17 $rows = array();
18 while($row = mysql_fetch_assoc($sql))
19 $rows[] = $row;
20
21 print(json_encode($rows).'\n');
22}
23
24// ----------------------------------------------------------------
25
26$cut = "";
27if (isset($_POST['t']))
28{
29 $cut = $_POST['n'].' '.$_POST['t'];
30
31 $d = new DateTime($cut);
32 if ($d->format("His")<120000)
33 {
34 $d->add(new DateInterval('P1D')); // PnYnMnDTnHnMnS
35 $cut = $d->format("Y-m-d H:i:s");
36 }
37
38 $cut = " AND fStart>'".$cut."' ";
39}
40
41// ----------------------------------------------------------------
42
43require_once 'config.php';
44
45$db = mysql_connect($dbhost,$dbuser,$dbpass);
46if (!$db)
47 die(mysql_error());
48
49if (!mysql_select_db($dbname, $db))
50 die(mysql_error());
51
52/*mixed date_sunrise ( int $timestamp [, int $format = SUNFUNCS_RET_STRING [, float $latitude = ini_get("date.default_latitude") [, float $longitude = ini_get("date.default_longitude") [, float $zenith = ini_get("date.sunrise_zenith") [, float $gmt_offset = 0 ]]]]] )*/
53
54query("SELECT DISTINCT(DATE(ADDTIME(fStart, '-12:00'))) AS 'd' FROM Schedule");
55query("SELECT fSourceKEY AS 'key', fSourceName AS 'val' FROM Source WHERE fSourceTypeKEY=1");
56query("SELECT fMeasurementTypeKEY AS 'key', fMeasurementTypeName AS 'val' FROM MeasurementType");
57query("SELECT * FROM Schedule WHERE DATE(ADDTIME(fStart, '-12:00:00')) = '".$_POST['n']."'".$cut."ORDER BY fScheduleID ASC, fMeasurementID ASC");
58
59//sleep(3);
60
61//print($test1."|".$test2."|".$test3."|SELECT * FROM Schedule WHERE DATE(ADDTIME(fStart, '-12:00:00')) = '".$_POST['day']."'".$cut."ORDER BY fScheduleID ASC, fMeasurementID ASC\n");
62
63?>
Note: See TracBrowser for help on using the repository browser.