OK.
Sur chaque option de ton select, tu ajoutes ça, mettons que ta value date soit "01-06-2020", au même format que ton affichage.
<option value="'.<?php echo $ma_date_1;?>.'" <?php echo (date('d-m-Y')==$ma_date_1?'selected':NULL); ?>>'.<?php echo $ma_date_1;?>.'</option>
Ou bien plus lisible à mon goût, même si ce n'est pas la mode, tu fais tout ton select en PHP dans ta boucle.
1 2 3 4 5 6 7 8 9 10 11 12 13
| $select_dates='<label for="myselect1" id="lblmyselect1" style="min-height:13px">La Date</label>
<select name="myselect1" id="myselect1">'."\n";
foreach($dates as $date){
$selected='';
if(date('d-m-Y')==$date){
$selected=' selected ';
}
$select_dates.='<option value="'.$date.'"'.$selected.'>'.$date.'</option>'."\n";
}
$select_dates.='</select>'."\n";
echo $select_dates; |
Partager