Musa :
The idea I need to add a new year to my select box when it comes like we in 2020 so I need when 2021 just add it to my select box with keep 2020 as well without delete it
I used the date('Y') it just for now
<option value="{{ date('Y') }}"> {{ date('Y') }} </option>
Any suggestion?
showdev :
If you'd like to start with 2020 and add new years as they arrive, I suggest using a for
loop to iterate from 2020 to the current year.
Something like this:
for ($year=2020; $year<=date('Y'); $year++) {
echo "<option>$year</option>";
}
Or if using Laravel/Blade:
@for ($year=2020; $year<=date('Y'); $year++)
<option>{{ $year }}</option>
@endfor
Or even:
{{ Form::selectRange('year', 2020, date('Y')) }}
For reference:
PHP Control Structures - for loops
Laravel - Templates - Other Blade Control Structures (see Loops)
Laravel - Forms & HTML - Drop-Down Lists (see selectRange)
Guess you like
Origin http://43.154.161.224:23101/article/api/json?id=302332&siteId=1