PDA

View Full Version : Calendars [opinions needed]



Digitalosophy
June 20th, 2004, 06:02 PM
Hey guys, looking for some advice.

I have a client who is in need of a dynamic calendar which of course they need to update. Doesn't really matter if it's php or asp.

Now..

I'n my head, I don't see why storing the information in a database would be a problem. Just have all months and days in a database, make a layout which generates the database information accoring to date.

Have a CMS which you can update all this data, and I should be good to go right?

As far as database structure I was thinking of having each month be it's own table, and of course have the day's and events in the proper table.

Thing that concerns me most is leap year :sigh:

How will a leap year effect this?

Also as far as the SQL statement, I'm thinking of generate the data where month = current month. Is this wrong?

Basically I know it's going to be a somewhat big project, but I also don't think it's too too hard to accomplish.

Any advice or suggestions would be great. if anyonehas done this before please let me know how you went about it.

I'm not looking for code or source files, although examples would be nice :)

Thanks fellas,
Digital

Jerryscript
June 20th, 2004, 08:22 PM
You can set up your database with 29 days in February, and let your actionscript call to the 29th day only when it is a leap year.

Here's a thread on an actionscript calendar I wrote in Ming and Steffan converted to a FMX fla. The method of storing to the SharedObject can be converted easily to storing to a database via PHP. There is also code for all the basic US holidays (Easter is tough, being based on the full moon cycle).

http://www.kirupaforum.com/forums/showthread.php?t=55370&highlight=calendar

Digitalosophy
June 20th, 2004, 11:18 PM
Ok that's excellent, that you much for that.

You say the SharedObject can easliy be converted to stroing database data. How would I go about that?

You see, this must be updatable by an admin using a web based CMS. So that is a big concern.

Thanks again :)

Hans Kilian
June 21st, 2004, 02:20 AM
Storing each day in a database is pretty inefficient. Why not just store the events?

Calculating how many days are in a given month is pretty easy. And the Date object can tell you what day of the week each day is.

Leap year is easy to calculate. If year modulus 4 is 0 then it's a leap year and then feburary has 29 days. There are exceptions to that rule, but it won't break down until 2100.

Digitalosophy
June 21st, 2004, 04:23 PM
Storing each day in a database is pretty inefficient. Why not just store the events?

Calculating how many days are in a given month is pretty easy. And the Date object can tell you what day of the week each day is.

Leap year is easy to calculate. If year modulus 4 is 0 then it's a leap year and then feburary has 29 days. There are exceptions to that rule, but it won't break down until 2100.


ok after some research i understand what i need to do here.

Hans: you say
Why not just store the events?.

great point, and i understand now why. but let me ask you....

I don't understand exactly how to do go about it... I mean I do but I don't at the same time.

How would you go about that?

I guess my real question is how would you set up the database?

I know my questions are vague, but at the moment I'm having trouble planning my structure of this system. I found a great tutorial here on creating the calendar.

http://www.phpfreaks.com/tutorials/83/0.php

So the actual creation of the calender won't be a problem (i don't think anyway :))

It's managing the content you see.

What are your thaughts/solutions?

Also I thank you for taking the time
Digital

Hans Kilian
June 21st, 2004, 05:00 PM
How your database (well, you'll probably only need a single table) is structured, depends on your requirements. Mainly if an event can span several days or only be on a single day.
And do you need to store what time the event takes place as well?

Anyway, a rough starting point could be a table with 3 columns:
- a key column. This could be an autogenerated integer.
- a date field for storing when the event takes place
- a text field that stores a description of the event.

Then you need to make a 'CRUD' page (Create, Read, Update, Delete) that will let you maintain the contents of the table.

And finally a page that lays out a calendar for a specific month and shows the events that take place in that month. If that's the kind of presentation you want to give your users. A simple ordered list of events could also be enough...

APDesign
June 21st, 2004, 05:14 PM
If you are in a rush you can buy a great calendar for $14.95 from http://www.easilysimplecalendar.com/ It is really easy to implement, update, and mod.

I'm planning on writing my own calendar script soon, I need a new php project to work on :thumb:

Digitalosophy
June 21st, 2004, 05:23 PM
Anyway, a rough starting point could be a table with 3 columns:
- a key column. This could be an autogenerated integer.
- a date field for storing when the event takes place
- a text field that stores a description of the event.

Then you need to make a 'CRUD' page (Create, Read, Update, Delete) that will let you maintain the contents of the table.



Ok this is great, I totally understand everything you said and I thank you, as this clears up most of my problems.

However...
I still am consfused on how to generate the data into the proper dates for the events.

Please excuse me as my brane is totally frozen on this matter. I'm going to create the calendar now (going to start it anyway). And leave the events for last. Maybe then it will be more clear on how to generate the events to the proper days.

@ APDesign: Thanks for that link, but I would really like to tackle this project by hand coding it myself. I think it will be a good learning experience.

Thanks again guys :)

APDesign
June 21st, 2004, 05:26 PM
No problem, I feel the same way. Looking at the way the calendar works though might give you some good ideas, I know it helped me put things into perspective or at least make it seem not as intimidating. It really is a lot more "simple" than I thought it would be.

Digitalosophy
June 21st, 2004, 05:29 PM
I know it helped me put things into perspective or at least make it seem not as intimidating. It really is a lot more "simple" than I thought it would be.

YES! exactly, after doing some research and taking to you guys this project does seem less intimidating.

I'll keep you guys posted
:thumb:

Hans Kilian
June 21st, 2004, 06:00 PM
However...
I still am consfused on how to generate the data into the proper dates for the events.

When you generate the calendar, you're going to end up with a loop that gets executed once for each day. In that part of the code you'll want to output HTML to render a table cell for that day.

There you can check if there is an event (or more events) for that day by doing a SELECT query on the table where you retrieve the events for the date in question.

As for the algorithm to generate a calendar for any given month, it could be something like this:
1) Find out what week-day the first of the month falls on.
2) Find out what date is a sunday in that week. This is your starting date.
3) For each week generate a table row with 7 table cells.
4) Stop when you get to a week where the sunday is in the next month

(This assumes that your weeks start on a sunday. Here in Denmark they start on mondays).

oli99via
January 8th, 2008, 07:02 PM
Hey, what do you guys think of this Easy PHP Calendar?

http://www.easyphpcalendar.com

I would like to get some opinions before I try to use it on my website.