$con=mysqli_connect("localhost","root","sensorall","sensorroom");
// Check connect
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
if(!empty($_POST['dateStart'])){
$sql = "SELECT * FROM `power` where TIME BETWEEN '".$_POST['dateStart']."' and '".$_POST['dateEnd']."' ORDER BY `time` ";
}else{
$sql = "SELECT * FROM `power` where TIME ORDER BY `time` ";
}
//echo $sql;
$result = mysqli_query($con,$sql);
while($row = mysqli_fetch_array($result)) {
$datax1[] = $row["time"];
$datay1[] = $row["mwh"];
//$datay2 [] = $row["lightout"];
// $y2_axis[$i] = $row["lightout"];
}