Hi all, I have managed to make a calendar that shows all of the dates in a month laid out appropriately. However, I need to add events to the calender. I would be able to do this if the event was a one-day event but they're not.
I have an events table in my database that has a beginning and end date, so how can I put this onto the calendar, I guess I will need to use some sort of loop but unsure exactly how this can be done! Any help is appreciated as always
First you need to grab all events from you calendar that fall withing the current date. These are the events for which holds that:
- Their end date is in the current month, OR
- Their start date is in the current month, OR
- Their start date is before the current month, and the end date is after the current month (i.e., an event that spans the complete month)
(by "current month" I mean the month your calendar is currently showing)
When you have these events, you just loop through the dates, and for each date check which of the events should be shown there.
There may be different approaches, but this is the approach I took a while back, and it works just fine
If every day in say, a 3 day event contains the same activities, at the same times, then ScallioXTX's solution will be fine.
If every day in your event is different, then you could consider a solution whereby you make three one day events.
Only you know the answer to this dilemma based upon your knowledge of the majority of types of events you will have to cater for.
Overall, focus your attention more on how you are going to get your events out - more than how you are going to input and manage them.
Hey guys, thanks for the pointers, much appreciated I'm just really stuck on how to get an event to fill each date column with the events until it reaches the events end date. There will be more than one event also in a month so I may have several events on one date, so how would I display this...using multiple loops?
So are you using start_date, end_date fields in your table, or are you using one entry per day?
Hey Cups, apologies for the long delays in replying, currently have limited internet access. Yes, I have a start and end date in my table...
Hey man, any further ideas on what I could do about this? Trying to build an availability calendar...
Go to advanced search, search for calendar and limit the results to the PHP forums. There you will find a range of discussions.
I do not personally use date_start, date_end style tables so cannot help you. Plenty of others do though.