getChartData.php

 avatar
unknown
php
a year ago
498 B
4
Indexable
<?php
include("koneksi.php");

// Periksa koneksi
if ($koneksi->connect_error) {
    die("Connection failed: " . $koneksi->connect_error);
}

$sql = "SELECT * FROM sensor ORDER BY time_stamp DESC limit 7 ";
$result = $koneksi->query($sql);

$data = array();
if ($result->num_rows > 0) {
    // Ambil data dari setiap baris
    while ($row = $result->fetch_assoc()) {
        $data[] = $row;
    }
} else {
    echo "0 results";
}
$koneksi->close();

echo json_encode($data);
Editor is loading...
Leave a Comment