Created
February 6, 2014 22:36
-
-
Save matbor/8853902 to your computer and use it in GitHub Desktop.
This is what is used by index_hs_temps_multi.php to get my temperature data in json format for my highcharts (highstock)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$path = $_SERVER['DOCUMENT_ROOT']; | |
$path .= "/dbconnection/temperature_dbinfo.php"; | |
require($path); | |
$interval = $_GET['interval']; | |
$location = $_GET['location']; | |
$con = mysql_connect($mysqlserver,$username,$password); | |
if (!$con) { | |
die('Could not connect: ' . mysql_error()); | |
} | |
mysql_select_db($database, $con); | |
$return_arr = array(); | |
// this will return x days | |
$fetch = mysql_query(" | |
SELECT | |
timeof, | |
message | |
FROM | |
temperatures | |
WHERE | |
DATE(timeof) BETWEEN DATE_SUB(CURDATE(), INTERVAL $interval DAY) AND CURDATE() AND locationmap = '$location' | |
"); | |
// using this query if we want ALL the data | |
if ($interval == 'all') { | |
$fetch = mysql_query(" | |
SELECT | |
timeof, | |
message | |
FROM | |
temperatures | |
WHERE | |
locationmap = '$location' | |
"); | |
} | |
$i=0; | |
while ($row = mysql_fetch_array($fetch, MYSQL_ASSOC)) { | |
$rows[$i]=array(strtotime($row[timeof])*1000 ,(float)$row[message]); | |
$i++; | |
} | |
echo json_encode($rows); | |
mysql_close($con); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment