Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //setting header to json
- header('Content-Type: application/json');
- //database
- define('DB_HOST', 'localhost');
- define('DB_USERNAME', 'admin');
- define('DB_PASSWORD', 'eass');
- define('DB_NAME', 'EMMA');
- //get connection
- $mysqli = new mysqli(DB_HOST, DB_USERNAME, DB_PASSWORD, DB_NAME);
- if(!$mysqli){
- die("Connection failed: " . $mysqli->error);
- }
- //query to get data from the table
- $query = sprintf("SELECT ts, Gesamtwirkleistung, Gesamtscheinleistung, Gesamtblindleistung FROM Gleichrichter_Mix");
- //execute query
- $result = $mysqli->query($query);
- //loop through the returned data
- $data = array();
- foreach ($result as $row) {
- $data[] = $row;
- }
- //free memory associated with result
- $result->close();
- //close connection
- $mysqli->close();
- //now print the data
- print json_encode($data);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement