<?php

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

  require '../php/database.php';

  //query to get data from the table
  $query = sprintf("SELECT `userID`, `username`, `firstRun`, `adminEmail`, `email1`, `email2`, `email2Enabled`, `email3`, `email3Enabled` FROM `users` ORDER BY ".userID." ASC");

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

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

  //now print the data
  print json_encode($dataWindow);
  // free memory associated with result
  $result->close();

  //close connection
  $mysqli->close();
  // print_r(json_encode($dataWindow));