getDataTable.php

 avatar
unknown
php
a year ago
391 B
3
Indexable
<?php
// Koneksi ke database
require('koneksi.php');
$sql = "SELECT * FROM sensor ORDER BY time_stamp DESC ";

$result = $koneksi->query($sql);

if ($result->num_rows > 0) {
    $data = array();
    while ($row = $result->fetch_assoc()) {
        $data[] = $row;
    }
    echo json_encode($data);
} else {
    echo json_encode([]);
}

// Tutup koneksi
$koneksi->close();
Editor is loading...
Leave a Comment