The overall outline:
There's lots of variation that may occur here, but roughly (in semi-psuedo code):
Within page consists of the calendar (results in JSON notation)
Obviously, you will find various ways that this may be done, but this is why it might flow. This really is only a good example shedding this code right into a PHP page on the server won't work, it's only designed to demonstrate how generally it might flow.