connect_error) {
die("Connection failed: " . $conn->connect_error);
}
#$sql = "SELECT * FROM sensors_info ORDER BY sid DESC";
$sql = "SELECT * FROM sensors_info WHERE sensor_plot = 'on' AND sensor_state = 'on' AND sensor_type = 'Temperature' ORDER BY sid ASC";
$result = $conn->query($sql);
?>
num_rows > 0) {
echo '
';
}
?>
query($sql);
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
if ($row["sensor_name"] != "") {
$html_id = $_POST['SensorID'];
$html_name = $row["sensor_name"];
}
else {
$html_id = $_POST['SensorID'];
$html_name = $row["sensor_id"];
}
}
}
else {
$html_id = $_POST['SensorID'];
$html_name = $html_id;
}
}
else {
}
if(isset($_POST['Submit']))
{
if ($_POST['TimeLine'] == "1h") { $timeline = "Hour"; }
if ($_POST['TimeLine'] == "1d") { $timeline = "Day"; }
if ($_POST['TimeLine'] == "1w") { $timeline = "Week"; }
if ($_POST['TimeLine'] == "1m") { $timeline = "Month"; }
if ($_POST['TimeLine'] == "1y") { $timeline = "Year"; }
}
else {
$_POST['TimeLine'] = "1h";
if ($_POST['TimeLine'] == "1h") { $timeline = "Hour"; }
}
if ($html_id != "") {
$filepath = '/var/www/plots/'.$html_id.'_'.$_POST['TimeLine'].'.png';
if (file_exists($filepath)) {
echo '
'.$html_name.' '.$timeline.' Plot: |  |
';
}
else {
echo '
'.$html_name.' '.$timeline.' Plot: | The plot will show up after the first cycle of plot creation which happens every 10 minutes. Please check back after 10 minutes. |
';
}
}
else {
echo 'There are no plots enabled currently. Please go to the admin section and enable a plot for a sensor to put it on the list.
';
}
?>