Let's say that I have created two tables in my database:
`INSERT INTO `months` (`month_id`, `month_name`) VALUES ('1', 'January');`
and
`INSERT INTO `weeks_and_days` (`week_id`, `week_nr`, `day_nr`) VALUES ('1', '1', '1'), ('2', '1', '2'), ('3', '1', '3'), ('4', '1', '4'), ('5', '1', '5'), ('6', '1', '6'), ('7', '1', '7');`
What should be the correct PHP and SQL code to get exactly the following nested JSON:
{
"month_name": "Yanuary",
"week_nr": {
"1": [{
"day_nr": [1, 2, 3, 4, 5, 6, 7]
}]
}
}
I read a couple of answers and tried to apply them in my code, but I faild. I need some simple formula as I am quite new in programming.