<?php
  //setting header to json
  header('Content-Type: application/json');
  header("Access-Control-Allow-Origin: *");


  $id = $_GET["i"];  // get internal sensor id from js
  require '../php/database.php';

  $query = 'SELECT versionInfo.versionID, versionType.versionType, versionInfo.change
  FROM versionInfo
  LEFT JOIN versionType
  ON versionInfo.versionTypeID = versionType.versionTypeID
  WHERE versionInfo.versionID = '.$id.'
  ORDER BY versionType.versionTypeID ASC';

  //execute query
  $result = $mysqli->query($query);

  //loop through the returned data
  $dataWindow = array();
  foreach ($result as $row) {
    $dataWindow[] = $row;
  }

  //free memory associated with result
  $result->close();

  //close connection
  $mysqli->close();
  // print_r(json_encode($dataWindow));
  //now print the data
  print json_encode($dataWindow);
    