www/getispindellog.php

Wed, 10 Aug 2022 15:40:20 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Wed, 10 Aug 2022 15:40:20 +0200
changeset 838
ce5f39b66a51
parent 837
b5e2ff72cc73
permissions
-rw-r--r--

Switch co2pressure graph to MySQL

<?php

require_once('config.php');

if (isset($_GET["code"]))
	$code = $_GET["code"];
else
	$code = "CB0111";

$connect = mysqli_connect(DBASE_HOST, DBASE_USER, DBASE_PASS, DBASE_NAME);
if (! $connect) {
        die('Connect Error (' . mysqli_connect_errno() . ') ' . mysqli_connect_error());
}
mysqli_set_charset($connect, "utf8" );

$query = "SELECT * FROM log_ispindel WHERE code='".$code."' ORDER BY datetime;";
$result = mysqli_query($connect, $query) or die("SQL Error 1: " . mysqli_error($connect));
while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {

    $logs[] = array(
	'date' => substr($row['datetime'],0,16),
	'temperature' => $row['temperature'],
	'plato' => $row['plato'],
	'sg' => $row['sg'],
	'battery' => $row['battery']
    );
}
header("Content-type: application/json");
echo json_encode($logs);

mercurial