<?php
session_start();
error_reporting(1);
include('includes/config.php');

$start = $_POST['start'];
$end = $_POST['end']; 
$selectTable = SELECT_TABLE;

//devid required
//INNER JOIN table2
//ON table1.column_name = table2.column_name;
//$old = "SELECT * FROM `aws`  where  CreationDate >= '$start' and CreationDate <= '$end' order by CreationDate desc";
$old = "SELECT * FROM $selectTable order by CreationDate asc limit 5000";
$query = $dbh->prepare($old);
$query->execute();


$results = $query->fetchAll(PDO::FETCH_OBJ);

// $sql = "SELECT * FROM `alldevices`";
// $querydev = $dbh->prepare($sql);
// $querydev->execute();


// $devresults = $query->fetchAll(PDO::FETCH_OBJ);

//print_r("results: ", $results);
//$results[count($results) - 1] = $devresults;

if($query->rowCount() > 0){
	echo json_encode($results);

} else {
	$msg = "No data Found";
	echo json_encode(array("warning" => $msg));
}
	
?>
