Re: Calendar script - help
| From: | Kerry Kobashi | Date: | Tue, 05 Nov 2002 10:46:45 +0000 |
| Subject: | Re: Calendar script - help | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-122747@lists.php.net to get a copy of this message | ||
Your better off writing it from scratch than taking some pre-existing calendar/events code. Break
the problem up into two seperate pieces and solve for each - the creation of a calendar view and the
creation of a events view.
"I am a calendar and I know how to:"
Show a monthly view of myself
Move forward one month
Move backward one month
When a day is clicked I ask the events viewer to show an event
"I am a events viewer and I know how to:"
Show a event
Add a event
Edit a event
Delete a event
Create two classes, Calendar (calendar.php) and Events (events.php) that do the above.
The schema of the mySQL database is simple:
create table CalendarEvents
(
eventId int unsigned NOT NULL auto_increment primary key,
title varchar(64) NOT NULL,
eventDateStart DATE default '0000-00-00',
eventDateEnd DATE default '0000-00-00',
event text NOT NULL
);
Instead of entering in a date, why not click on the calendar's day to take you to a form that
will let you enter in the information. Here's some functions to helpin generating the calendar,
which is nothing more than a 6 row by 7 column table. Figure out the start of the first day in the
month via the FirstDayofMonth() function below. Create blank cells up to that day, then generate the
numbered days, along with numbered day hyperlinks that when clicked, contain the month, day, year
(e.g. hyperlink for the day contains Events.php?m=11d=5y=2002). This will create your context for
the day. You will be able to $_GET the params from within Events.php. This will allow you to
insert/delete/edit the record for that day in the database.
function IsLeapYear($year)
{
return(date("L", mktime(0,0,0,1,1,$year)));
}
function FirstDayofMonth($month, $year)
{
// 0 - Sunday.... 6 - Saturday
return(date("w", mktime(0,0,0,$month,1,$year)));
}
function DaysInMonth($month, $year)
{
return(date("t", mktime(0,0,0,$month,1,$year)));
}
Good luck,
Kerry Kobashi
Kobashi Computing
---------------------------------------------------------
"Ray Healy )" <ray@matrix-datanet.co.uk> wrote in message news:001a01c2835e$f9234d40$601786d9@mainserver...
Dear All
I spent days and days on this little project but still cannot get it to work (new to PHP as you
might guess).
I have a script which is a combination of tutorial scripts and free code to display a calendar with
colour coded cells for the events on each day.
The only way to enter events is to enter them one at a time. What I want to do is to be able to
enter either a start date and end date or start date and the number of days. This will then enter a
new line in the mySQL database for each day. There would only ever be one vent per day.
I have the following fields at present in the database and would probably need another field (say
number of days)
id int (auto_increment) - eventdate date ('0000-00-00') - title (varchar) - event (blob)
Can anyone help me as I have searched them web and mail lists to no avail. Everything that is
available is excellent but does too much for what I need.
Summary:- a calendar that can colour code the background cells if there is an event title in the
mySQL database and to be able to enter the event for multiple days.
Any help would be very much appreciated.
Thanks for your time
Ray