<?php

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


  $id = $_POST["id"];  // get internal sensor id from js
  $driverID = $_POST["driver"];  // get value
  require '../php/database.php';

  $query = 'SELECT rules.ruleID, rules.ruleTypeID, rules.ruleName, rules.email, rules.alert, rules.enabled, rulesType.ruleType
  FROM rules
  LEFT JOIN rulesType
  ON rules.ruleTypeID = rulesType.ruleTypeID
  ORDER BY rules.ruleID 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);