PHP
  Home arrow PHP arrow Page 2 - A Useful Event Calendar Written In PHP
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
PHP

A Useful Event Calendar Written In PHP
By: Mitchell Harper
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 142
    2002-06-10

    Table of Contents:
  • A Useful Event Calendar Written In PHP
  • The event calendars logic
  • Creating the calendar
  • Highlighting days with events
  • Adding an event
  • Conclusion

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    A Useful Event Calendar Written In PHP - The event calendars logic


    (Page 2 of 6 )

    As the name suggests, an events calendar stores events. These events are shown along with the calendar when a specific day is selected, such as the 11th June, 2002. The calendar will display events in a "by month" format, meaning that each of the thirty or so days for a month will be shown on one page. If any of the days have events "attached" to them, then that day will be highlighted in blue. Likewise, today's date will be highlighted in grey, and the currently selected day (if any) will be highlighted in red.

    If we click on a day, then all of the events attached to that day will be displayed, along with a form through which we can add a new event. All events include a link to remove them.

    So, just to get you excited, here's what the calendar will look like when we're finished:

    A sneak preview of our calendar

    Today is the 11th, so see how June 11th is highlighted in grey? The PHP code to drive our calendar will be stored in one file called cal.php. Cal.php will work with a flat text file called cal_events.text. Cal_events.text will contain the list of events for our calendar. Each event is stored in the following format:

    [Month] [Day] [Year]
    [Event Name]
    [Event Description]

    So if I had an event reminding me that today is the 11th of June, then it would be stored in cal_events.text like this:

    06 11 2002
    Today is the 11th Of June!
    Guess what, today is the 11th of June. Woohoo!

    Each entry takes up three rows, and we can use PHP's powerful file and array functions to effortlessly grab each event from the flat file and display/delete it accordingly.

    Cal.php is separated into three different sections:
    • Add Post: The AddPost() function allows us to add an event to a specific day of our calendar.
    • Delete Post: The DelPost() function allows us to delete an event from our calendar.
    • Display Calendar: We display the calendar by making use of PHP’s powerful date manipulation functions, by using for loops, and also by opening the events file and flagging particular days that contain events, etc.
    Each day in a particular month is represented as part of a table as a <td> cell. The calendar was designed to take advantage of Internet Explorer's Cascading Style Sheet (CSS) abilities, so at the top of cal.php I have defined some styles for various parts of the calendar:

    .normal {
    font-family: Verdana;
    font-size: 8pt;
    color: #000000;
    height: 20;
    padding-left: 5pt;
    }


    This style is used for normal days. By a normal day I mean a day that isn't today and a day that contains no events.

    .today {
    font-family: Verdana;
    font-size: 8pt;
    color: #FFFFFF;
    background-color: #CACACA;
    height: 20;
    padding-left: 5pt;
    }


    This style is used to highlight the current day, making it easy to work out what the day is and how many days there are until the end of the month, etc.

    .selected {
    font-family: Verdana;
    font-size: 8pt;
    color: #FFFFFF;
    background-color: #C00000;
    height: 20;
    padding-left: 5pt;
    }


    When we click on a day to view its events, this style will highlight it in a bright red, making it stand out from the rest of the days around it.

    .event {
    font-family: Verdana;
    font-size: 8pt;
    color: #000000;
    background-color: #C6D1DC;
    height: 20;
    padding-left: 5pt;
    }


    Lastly we have the event style, which is used for any day that is attached to one/more events from the events file.

    After adding a couple of events and selecting a day, here's how our calendar will look:

    Our calendar in action

    In the screen shot above, days 12, 24 and 28 contain events. It is the 11th of June, so the 11th is highlighted in grey, and we have the 12th day selected, so it is highlighted in red. Note the events for the 12th are shown under the "Today's Events" section just under the calendar.

    Well now that we know a bit more about how the calendar functions, let's jump right in and take a look at how to code up the calendar.

    More PHP Articles
    More By Mitchell Harper


       · Good Tutorial.The full source code could be nice, as I am having problems with the...
       · I cannot seem to locate the mentioned support files link! Any help would be...
       · can we have the source code please.thank you
       · Please send me the complete source code, somethings wrong withmy coding, i can't...
       · sir ,please i m in need to get source code ......i tried alot but i ended with some...
       · we need source code very urgently..how to get source code..Kindly help me in that...
       · To all the commenters so far:I'm not the original author of this article, and...
       · By the way, that Anonymous Loozah was me.So here's the info so far. I've been...
       · I was looking for a MySQL one, so if you can give me that, that would be cool, my...
       · My morning is fairly busy, but I'll email you my file after lunch.
       · Hi, please can I have a copy of both the flat-file and mysql code, I can't seem to...
       · Hi, could i please have a copy of the flat file and the SQL code please. You can...
       · Hey!I would also like to have the script that you mySQL that you mention here....
       · Hi there I tried to follow your instructions but I can't seem to get it right I was...
       · Hello , can u send me a copy of the flat file and the SQL code too please. My email...
       · hey i'm really really interested in an event calendar with php and mysql (or text...
       · hi I am working on a site, for my self, and I found that code quite helpfull, if you...
       · Please can you mail me the code on aeshang@hotmail.comThank you !!!
       · hello! could you please send me the functional code for the calendar? indeed, it...
       · it's very useful, but don't know why i can did it can we have the source code...
     

    PHP ARTICLES

    - Making Usage Statistics in PHP
    - Installing PHP under Windows: Further Config...
    - File Version Management in PHP
    - Statistical View of Data in a Clustered Bar ...
    - Creating a Multi-File Upload Script in PHP
    - Executing Microsoft SQL Server Stored Proced...
    - Code 10x More Efficiently Using Data Access ...
    - A Few Tips for Speeding Up PHP Code
    - The Modular Web Page
    - Quick E-Commerce with PHP and PayPal
    - Regression Testing With JMeter
    - Building an Iterator with PHP
    - PHP Frontend to ImageMagick
    - Using PEAR's mimeDecode Module
    - Incoming Mail and PHP







    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 Hosted by Hostway
    Stay green...Green IT