connect_error) { die("Connection failed: " . $conn->connect_error); } $sqlnew = "select location as light from SensorData where sensor like '$sensor' ORDER BY id DESC LIMIT 1"; if ($result = $conn->query($sqlnew)) { while ($row = $result->fetch_assoc()) { $row_light = $row["light"]; } $result->free(); } $percent = (1 - $location / $row_light) * 100; //$percent = 0 - $percent; $anone = number_format($percent, 0); $anone = 0 - $anone; // echo $location."
"; // echo $row_light."
"; // echo $anone; if($anone >=80 ){ $location = $row_light; } //echo "konec:".$location; $sql = "INSERT INTO SensorData (sensor, location, value1, value2, value3) VALUES ('" . $sensor . "', '" . $location . "', '" . $value1 . "', '" . $value2 . "', '" . $value3 . "')"; if ($conn->query($sql) === TRUE) { echo "New record created successfully"; } else { echo "Error: " . $sql . "
" . $conn->error; } $conn->close(); } else { echo "Wrong API Key provided."; } } else { echo "No data posted with HTTP POST."; } } else { $sql = "SELECT id, sensor, location, value1, value2, value3, reading_time FROM SensorData order by reading_time desc limit 10"; echo ''; if ($result = $conn->query($sql)) { while ($row = $result->fetch_assoc()) { // $row_id = $row["id"]; $row_sensor = $row["sensor"]; $row_location = $row["location"]; $row_value1 = $row["value1"]; $row_value2 = $row["value2"]; $row_value3 = $row["value3"]; $row_reading_time = $row["reading_time"]; //$row_reading_time = date("Y-m-d H:i:s", strtotime("$row_reading_time + 4 hours")); if($row_sensor == "Byt"){ echo ''; } else { echo ''; } } $result->free(); } $conn->close(); } function test_input($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data; }
Kde Svetlo Vlhkost Teplota Tlak Timestamp
' . $row_sensor . ' ' . $row_location . ' ' . $row_value1 . ' ' . $row_value2 . ' ' . $row_value3 . ' ' . date("l dS \o\f F Y h:i:s A",strtotime("$row_reading_time")) . '
' . $row_sensor . ' ' . $row_location . ' ' . $row_value1 . ' ' . $row_value2 . ' ' . $row_value3 . ' ' . date("l dS \o\f F Y h:i:s A",strtotime("$row_reading_time")) . '