Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $server="xxx";
- $user="xxxt";
- $pass="xxx";
- $db1="xxx";
- $conn = mysqli_connect($server, $user, $pass, $db1);
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- $query = "SELECT * FROM tempLog";
- $result = $conn->query($query);
- $jsonArray = array();
- if ($result->num_rows > 0) {
- while($row = $result->fetch_assoc()) {
- $jsonArrayItem = array();
- $jsonArrayItem['label'] = $row['czas'];
- $jsonArrayItem['value'] = $row['temperature'];
- array_push($jsonArray, $jsonArrayItem);
- }
- }
- $conn->close();
- header('Content-type: application/json');
- echo json_encode($jsonArray);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement