Advertisement
Guest User

Untitled

a guest
Nov 3rd, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. <?php
  2. echo "<meta http-equiv='refresh' content='600' charset='UTF-8' />";
  3. date_default_timezone_set('Europe/Sofia');
  4.  
  5. $servername = "localhost";
  6. $username = "arduino";
  7. $password = "testtest";
  8. $dbname = "arduino";
  9.  
  10. // Create connection
  11. $conn = mysqli_connect($servername, $username, $password, $dbname);
  12. // Check connection
  13. if ($conn->connect_error) {
  14. die("Connection failed: " . $conn->connect_error);
  15. }
  16.  
  17. $sql = "SELECT number, date, dht1_t, dht1_h, dht2_t, dht2_h FROM temperature";
  18. $result = $conn->query($sql);
  19.  
  20.  
  21.  
  22.  
  23. if ($result->num_rows > 0) {
  24. // output data of each row
  25. while($row = $result->fetch_assoc()) {
  26. //$date_array[]=$row['date'];
  27. //$temp1_array[]=$row['dht1_t'];
  28. //$temp2_array[]=$row['dht2_t'];
  29. echo "<br> N: ". $row["number"]. " - Date: ". gmdate("Y-m-d H:i:s", $row["date"]+7200). " | Temp: " . $row["dht1_t"] . " - Humidity: " . $row["dht1_h"].
  30. " | Temp 2: " . $row["dht2_t"]. " - Humidity: ". $row["dht2_h"]. "<br>";
  31. }
  32. print_r($date_array);
  33. print_r($temp1_array);
  34. print_r($temp2_array);
  35.  
  36. } else {
  37. echo "0 results";
  38. }
  39.  
  40. $conn->close();
  41. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement