getTemperature.php
unknown
php
6 months ago
673 B
3
Indexable
<?php header('Content-Type: application/json'); header('Access-Control-Allow-Origin: *'); $servername = "localhost"; $username = "root"; // Update if your username is different $password = ""; // Update with your MySQL password $dbname = "test_aeroscan_db"; $conn = new mysqli($servername, $username, $password, $dbname); if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $sql = "SELECT * FROM temperature"; $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