Created
December 25, 2015 12:47
-
-
Save anonymous/5a678b48f4e06eadd874 to your computer and use it in GitHub Desktop.
data.php
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 | |
// Include database connection | |
include 'connect.php'; | |
// Declare result array | |
$result = array( | |
'nameA' => ' Temperatur', | |
'nameB' => ' Setpoint', | |
'category' => array(), | |
'data1' => array(), | |
'data2' => array(), | |
); | |
// Get MySQL connection resource | |
$mysql = GetMyConnection(); | |
// Get data SQL parameter from request query or default date | |
$dateParam = array_key_exists('dateParam', $_GET) ? mysql_real_escape_string($_GET['dateParam']) : '2015-12-24'; | |
//$dateParam = '2015-12-20'; | |
// Execute select query | |
if(!$query = mysql_query("SELECT `Time`,`SP1`, `Tilgang` FROM `ebpool` WHERE `Time` LIKE '" . $dateParam . "%'", $mysql)) | |
{ | |
die("Query error: " . mysql_errno($mysql) . ": " . mysql_error($mysql)); | |
} | |
// Get each table row | |
while($row = mysql_fetch_array($query)) | |
{ | |
$result['category'][] = $row['Time']; | |
$result['data1'][] = $r['Tilgang']; | |
$result['data2'][] = $r['SP1']; | |
} | |
// Clean up database result | |
CleanUpDB(); | |
// Output result as JSON | |
echo json_encode($result, JSON_NUMERIC_CHECK); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment