I want to retrieve date from database with exclude 0000-00-00
into dropdown list. I tried using MIN()
function but it show the year from zero to current year.
<?php //year
$earliest_year = "SELECT MIN(YEAR(appl_date)) FROM table WHERE YEAR(appl_date)> '0000-00-00'";
$latest_year = date('Y');
?>
<select name="year" style="width:60px;">
<option value=""><?php echo $latest_year;?></option>
<?php
foreach ( range( $latest_year, $earliest_year ) as $year ) {
$selected = ($year == 'year') ? 'selected' : '';
echo '<option '.$selected.' value="'.$year.'">'.$year.'</option>';
}
?>
</select>
The expected result is to show the date from minimum to current year from database.