Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

calendar design

Status
Not open for further replies.

stasJohn

Programmer
Joined
May 6, 2004
Messages
155
Location
US
I'm working on an events calendar. In the calendar, I want each day to be a link if it has events.


here's what I came up with...

Code:
create array of all events that occur during the month called events_array (date, event_title, ... )

loop from 1 to number of weeks for the particular month {
  loop from sunday to monday {
     loop from 1st row to last row of events_array {
         
          check to see if current date exists in the array

     }
  }
}

this seems highly inneficient! Anyone know of a better method?

if anyone knows any good articles/tutorials, especially on recurring events, that'd be great.


well back to the drawing board.

thanks in advance.
 
From where are you getting the events? It would seem that you'd be best served by only filling that array with events for the current month, then displaying what you need.

If you're storing your events in a database, it should be simple to get the current month's events.



Want the best answers? Ask the best questions!

TANSTAAFL!!
 
yes I'm grabbing the dates from a database and yes, I'm only filling the array with events for the current month.

the issue is, when it grabs the events, its only grabbing the start dates for each event. So, when processing a calendar day... if the current date is in the array then we can just print the link and move on to the next calendar day. But, if the current date doesn't exist in events_array, I can't assume no events occur on the current day. I would have to check each event in events_array to see if it recurs and does it recur on the current day being proceseed.




 
How long might an event last. Can you have each day of the event be entered separately into the database. Then you would only have to sort your search by date. Depending on how they're displayed you could always add an additional flage saying if it is the first, middle, or last day of an event. Also, you could write a simple script to add each date to the database based on starting and ending dates. Just a thought.
 
thanks for the suggestions!

at first, i was only going to have one table,
events(id,start,end,recur_rule,...)

After some "google-ing" and suggestion above, it appears that creating all the recurring events ahead of time (when the event is created) is the best way to go.

Also, time has become an issue, so I'm not going to include "recurring events" with the application. But, I did my best designing the db so it can be incorporated later on.

This is my database schema if anyone is curious and wants to shoot me a suggestion. (thanks in advance)

events(eventsID,date,parent_eventID,detailsID,isException,...)
parent_event(parent_eventID, startdate, enddate, recur_ruleID)
details(detailsID, ... )
recur_rule(recur_ruleID, ... )


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top