score:0

you can do something like this:

getdata.php:

$dir = 'sqlite:/home/pi/aquasolar/sht30/log_db/db.sht.6.db';
$dbh = new pdo($dir) or die("cannot open the database");
$query = "select * from reading");
$r0 = array();
foreach ($dbh->query($query) as $row) {
  $r0 = $row[0];
}
$dbh = null;
echo json_encode($r0);

index.html

<!doctype html>
<html lang="en">
  ..
  <body>

    <script>
      // include jquery
      $.ajax({
        url: './getdata.php',
        type: 'get',
        success: (data) => {
          const parsed = json.parse(data);
          // use parsed to create your chart
        },
        error: (err) => {
          alert(err);
        }
      });
    </script>
  </body>
</html>

this is just an example of the logic that i use to resolve the problem. maybe there are some sintax error


Related Query

More Query from same tag