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 = 'Soil Sensor' ORDER BY sid ASC"; $result = $conn->query($sql); ?> num_rows > 0) { echo '
'; echo 'Sensor:  '; echo 'Plot Data For:  '; if (isset($_POST['SubSensor'])) { echo ''; } echo ''; echo 'Plot Time Line:  '; if (isset($_POST['TimeLine'])) { echo ''; } echo ''; 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"; } if ($_POST['SubSensor'] == "atemp") { $subsensor = "Air Temperature"; } if ($_POST['SubSensor'] == "stemp") { $subsensor = "Soil Temperature"; } if ($_POST['SubSensor'] == "humidity") { $subsensor = "% Humidity"; } if ($_POST['SubSensor'] == "light") { $subsensor = "Light Level"; } if ($_POST['SubSensor'] == "moist1") { $subsensor = "Soil Moister 1"; } if ($_POST['SubSensor'] == "moist2") { $subsensor = "Soil Moister 2"; } if ($_POST['SubSensor'] == "moist3") { $subsensor = "Soil Moister 3"; } if ($_POST['SubSensor'] == "moist4") { $subsensor = "Soil Moister 4"; } } else { $_POST['TimeLine'] = "1h"; if ($_POST['TimeLine'] == "1h") { $timeline = "Hour"; } $_POST['SubSensor'] = "atemp"; if ($_POST['SubSensor'] == "atemp") { $subsensor = "Air Temperature"; } } if ($html_id != "") { #GOT HERE $filepath = '/var/www/plots/'.$html_id.'_'.$_POST['SubSensor'].'_'.$_POST['TimeLine'].'.png'; if (file_exists($filepath)) { echo '

'.$html_name.'
'.$subsensor.'
'.$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.

'; } ?>