2
I need to make the SELECT field that today is like this (code below) displayed only the previous, current and next month. For example: As we are in the month of MAY so it will display in this select (html) only the months of APRIL MAY and JUNE and as we advance months will display MAY, JUNE and JULY....
I’m getting system ready to modify here in stage what I currently have code is this:
<select class="form-control" style="width: 200px;" name="Mes" id="Mes" onblur="verificaDataBaixaBoleto();">
<?php
$y = date('n'); // Mês 1 a 12
if($this->mes){
$mesatual = $this->mes;
}
for($x=1;$x<=12;$x++){
$mes = $x;
echo "<option";
if($x == $mesatual){
echo " selected='selected'";
}
echo " value='";
echo $mes;
echo "'>";
if($x == 1){
echo "Janeiro";
}
if($x == 2){
echo "Fevereiro";
}
if($x == 3){
echo "Março";
}
if($x == 4){
echo "Abril";
}
if($x == 5){
echo "Maio";
}
if($x == 6){
echo "Junho";
}
if($x == 7){
echo "Julho";
}
if($x == 8){
echo "Agosto";
}
if($x == 9){
echo "Setembro";
}
if($x == 10){
echo "Outubro";
}
if($x == 11){
echo "Novembro";
}
if($x == 12){
echo "Dezembro";
}
echo "</option>";
}
?>
</select>
I was trying to make some comparison so it could be exhibited, only I guess I got lost in logic.
Search today’s month in numbers, create two variables mesAnterior and mesSucessor, put their value as mesAtual -1 and mesAtual+1, makes a method that transfers the month from numbers to text, vualá
– Marciano.Andrade
I understand, but nothing that can take advantage of this code from above? I was already creating the $y = date('n'); // Month 1 to 12 to see...
– phpricardo