Skip to content

Instantly share code, notes, and snippets.

@kylejohnson
Created August 19, 2012 15:07
Show Gist options
  • Save kylejohnson/3395399 to your computer and use it in GitHub Desktop.
Save kylejohnson/3395399 to your computer and use it in GitHub Desktop.
// Find all of the sensors
$query_sensors = 'select distinct statisticName from statistics where statisticName != "Voltage"';
$result_sensors = mysql_query($query_sensors) or die ('query failed: ' . mysql_error());
while ($row = mysql_fetch_array($result_sensors)) {
$sensors[] = $row[0];
}
// For each sensor, query the values, put them into an individual array
foreach ($sensors as $sensor) {
$$sensor = "select statisticName, statisticValue from statistics where statisticName = '$sensor' and date(from_unixtime(statisticDate)) = curdate() order by statisticDate";
$result = $sensor;
$$result = mysql_query($$sensor) or die('Query failed: ' . mysql_error());
while ($row = mysql_fetch_array($$result)){
${datay_.$sensor}[] = $row[1];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment