Skip to content
Advertisement

PHP getting days of a month for a database

I’m making a calender planner with php/css/javascript/html.

I am trying to set each day of the month a class which is “day”. I tried using the following:

JavaScript

It does not work correctly, it kept duplicating every month and I am not sure how to correctly right the php to achieve what was intended.

I am only a beginner at php so I am not good at the moment

Could anyone help me with this?

If there any more information you need, please don’t hesitate to ask.

Thank you in advance! Chris

Advertisement

Answer

Your problem is that you are creating the whole thing in the while loop, so the days that are appended from the last call are also appended to the next output.

JavaScript

Update
Should you wish to keep what you already have

JavaScript

You only really to need to reinitialize the $days before each for after the if

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement