0
I didn’t know how to summarize the question, but here’s the thing:
I have a table (SQL) where there are columns nome
and data
.
There with PHP, I want to check the number of the week from the date and perform an action if there is a number x
of registered dates for each name.
Example:
NOME | DATA
João | 15/04/2019
Pedro | 15/04/2019
Maria | 15/04/2019
João | 17/04/2019
Pedro | 23/04/2019
João | 24/04/2019
I want to generate results like:
João tem 2 registros na semana 16.
Pedro tem 1 registro na semana 16.
Maria tem 1 registro na semana 16.
João tem 1 registro na semana 17.
Pedro tem 1 registro na semana 17.
Any idea how I could do that?
Get date with day of week, number of week, month and year
– Woss
Make a loop (for, while, etc.), and for each iteration of that loop, make another loop for the incidences of the name in the week.
– Pedro Filipe
You can do this directly from the database by calculating the week number, as already stated, and the instruction
group by
SQL to group similar records according to the rule you define. I believe that, with this, you already have enough material to research and try to do on your own. If you cannot, you can return and [Edit] the question by placing the code done and the result obtained.– Woss