I have a problem with fetch data. Date is saved in VARCHAR, which means it will string. I want to select data from 01-01-2019 to today in my table. So I have problem in where class condition.
Please check code below where I am trying to fetch data but it's still not working. I am using STR_TO_DATE(holiday_date, '%d-%m-%Y')
for change format string to date column.
<?php
echo $edate=date('d-m-Y');
$query="SELECT * FROM holidays where STR_TO_DATE(holiday_date, '%d-%m-%Y')='$edate' ORDER BY STR_TO_DATE(holiday_date, '%d-%m-%Y') asc ";
$stmt=$conn->prepare($query);
$stmt->execute();
$i=1;
while ($result = $stmt->fetch()) {
?>
<tr class="holiday-completed">
<td><?php echo $i;?></td>
<td style="display: none;"><?php echo $result['id'];?></td>
<td><?php echo $result['title'];?></td>
<td><?php echo $result['holiday_date'];?></td>
<td>
<?php $s=$result['holiday_date'];
$sdate = strtotime($s);
echo date('l',$sdate);
?>
</td>