I m using the 'BETWEEN' statement in php data objects to show posts made between 2 specific dates, but however, 'date from' is not working, although 'date to' is working properly, if I only set 'date from', nothing is displayed, but if I only set 'date to', correct posts are displayed, also if I set both 'date from' and 'date to', still correct posts are displayed, the problem is only when I select only 'date from', This is my code
$dateFrom = $_POST['dateFrom'];
$dateTo = $_POST['dateTo'];
$sql = "SELECT * FROM Main_Posts_table WHERE DATE(time) BETWEEN '$dateFrom' AND '$dateTo' ";
$data = $connect->query($sql);
echo "<center><table class = 'main_table'>";
foreach($data as $row){
echo "<tr><td><span id = 'time_of_post'>".$row['time']."</span><br/><br/>".$row['posts']."<br/><br/><span id = 'comment_button'>comments ↡</span></td></tr>";
}
echo "</table></center>";