Advertisement
Guest User

Untitled

a guest
May 16th, 2017
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. <?php
  2.  
  3. /* database connection information */
  4. $servername = "localhost";
  5. $username = "root";
  6. $password = "";
  7. $database = "sensores";
  8.  
  9.  
  10.  
  11. /* error messages */
  12. $messErr_connectionDatabaseFailed = "Error : connection failed. Please try later.";
  13.  
  14. $link = new mysqli($servername, $username, $password, $database);
  15.  
  16. /* If connection failed */
  17. if (!$link) {
  18. printf($messErr_connectionDatabaseFailed);
  19. printf("<br />");
  20. }
  21. /* If connection successed */
  22. else {
  23. $query = "SELECT id,tipoID_fk, id_arduino_fk, valores FROM sensor";
  24. //echo $query;
  25.  
  26. $results = $link->query($query);
  27. //echo $result->num_rows;
  28. if ($result->num_rows > 0)
  29. {
  30. while($row = $result->fetch_assoc())
  31. {
  32. echo "id: " . $row["id"]. " - Tipo: " . $row["tipoID_fk"]. "-id arduino: " . $row["valores"]. "<br>";
  33. }
  34. }
  35. else
  36. {
  37. echo "0 results";
  38. }
  39. }
  40. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement