[php] a

Viewer

  1. <?php
  2. $servername = "localhost";
  3. $username = "root";
  4. $password = "";
  5. $dbname = "eslolin";
  6. // Create connection
  7. $conn = mysqli_connect($servername, $username, $password, $dbname);
  8. // Check connection
  9. if (!$conn) {
  10.     die("Koneksi gagal: " . mysqli_connect_error());
  11. }
  12. //Query data untuk mengambil nilai sensor dengan IdSensor = 1
  13. $sql = "SELECT * FROM uts order by idMeja";
  14. //$sql = "SELECT * FROM sensor";
  15. $result = mysqli_query($conn, $sql);
  16. if (mysqli_num_rows($result) > 0) {
  17.     // output data of each row
  18.     while ($row = mysqli_fetch_assoc($result)) {
  19.         echo $row["statusMeja"] . ",";
  20.         //echo $row["statusSensor"];
  21.     }
  22. } else {
  23.     echo "0 results";
  24. }
  25. mysqli_close($conn);

Editor

You can edit this paste and save as new:


File Description
  • a
  • Paste Code
  • 29 Apr-2024
  • 719 Bytes
You can Share it: