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

$start = $_POST['start'];
$end = $_POST['end']; 
$param = $_POST['param'];
$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";

$startDate = date("Y-m-d", strtotime($start));
$endDate = date("Y-m-d", strtotime($end));  


$old = "SELECT $param, CreationDate from $selectTable WHERE DATE(CreationDate) BETWEEN '$startDate' AND '$endDate' ORDER BY $selectTable.`CreationDate` ASC";
 
$query = $dbh->prepare($old);
$query->execute();
$results = $query->fetchAll(PDO::FETCH_OBJ);

if($query->rowCount() > 0){
	echo json_encode($results);
	//echo json_encode(array("st" => $startDate, "en"=> $endDate));
} else {
	$msg = "No data Found";
	echo json_encode(array("warning" => $msg));
}
	
?>
