1
I have the following Table as Example:
data - chave primaria, contendo a data mesmo 2018-01-02.
diasemana - int, contendo o dias das semana tipo 1 para segunda, 2 para terça.
semanaAno - int, contendo o numero de semana do ano tipo 1 primeira semana do ano.
So I have:
<?php
$repetiacao = 3;
for ($i = 0; $i <= $repetiacao ; $i++) {
// aqui está o problema
}
?>
"Here’s the problem": I wanted each repeat loop to pick up the date, for example 2018-01-02 on the first loop after 2018-02-02 on the second and last 2018-03-02, according to the repeat amount
As you see it increases the MONTH in each repetition but still mine echo
I need you to be the field semanaAno
of my table. Then I arrived at logic more or less that in each loop I make a select
in the table showing the semanaAno
when data = data
. Can you help me?
Great, I’ll test here and return, thank you very much
– Luciano Coelho Pettersen
Dear Juven_v, yes gave certificate for what I need, in case I want to take also the day of the week of each tie would be like? example 2018-02-02 would be a Friday in case number 5
– Luciano Coelho Pettersen
i put the $data->format('N'); as I saw in the documentation. That’s right? That’s right?
– Luciano Coelho Pettersen
Yes, that is correct
– Juven_v
So all right, thank you.
– Luciano Coelho Pettersen
But a question and if the Year has dynamic, example I start in December 2018 and I have repeat 3 times, automatically it would have to skip to 2019
– Luciano Coelho Pettersen
You could use the function
add()
classDateTime
, available example here. Then the variable$i
of the for loop would not need to be concatenated with the date. The date advance would be done with the cited function.– Juven_v
I will consult and return thank you
– Luciano Coelho Pettersen