Untitled
unknown
plain_text
a year ago
661 B
5
Indexable
<?php header('Content-Type: application/json'); $servername = "localhost"; $username = "root"; $password = ""; $database_name = "versiune0"; $conn = new mysqli($servername, $username, $password, $database_name); if ($conn->connect_error) { echo json_encode(['error' => "Connection failed: " . $conn->connect_error]); exit; } // Select all data from the table $sql = "SELECT id, temp, humi, press, CO, dist, butt, posi FROM tabel"; $result = $conn->query($sql); $data = []; if ($result->num_rows > 0) { while ($row = $result->fetch_assoc()) { $data[] = $row; } } echo json_encode($data); $conn->close(); ?>
Editor is loading...
Leave a Comment