In my website's database, there are a lot of posts inserted with the date. I am making a post shorting system where a user selects a year from the dynamic dropdown and after pressing the submit button only that year's post will be visible on the website. Everything is going good but on the dynamic dropdown, a year is showing multiple time.
For example, There are 3 posts in my database which date is 2/2/2019 , 21/2/2019 , 22/3/2019. In my dynamic dropdown there I find 2019 3 times, but I need to show 2019 only one time.
I have tried some jQuery and JavaScript code but it did not work.
My code :
<?php
$query = "SELECT year(date) FROM `press_release` WHERE del_status=0";
$year = $conn->query($query);
?>
<form class="form-inline title" action="press_new.php" method="post">
<div class="form-group">
<label for="" style="color:#EB2227">Search by year</label>
<select name="year">
<option value="0">Please Select</option>
<?php while($row = mysqli_fetch_array($year)){ ?>
<option value="<?php echo($row['year(date)'])?>">
<?php echo($row['year(date)']) ?>
</option>
<?php } ?>
</select>
<button type="submit" name="submit" class="btn btn-default" style="background-color:#EB2227">Submit</button>
</div>
</form>