PHP
  Home arrow PHP arrow Page 5 - 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 - Adding an event


    (Page 5 of 6 )

    If a particular day is selected, then we also show a form to add a new event to the current day under the list of events. The form is just basic HTML and looks like this:

    The form to add a new event

    When the new event form is submitted, the AddPost function is called with the selected day, month and year, as well as the name and details of the post:

    function AddPost($Day, $Month, $Year, $Name, $Desc)

    AddPost simply opens the events file and output the details of the new post, like this:

    // Add this event to the events file
    $fp = @fopen($_SERVER["DOCUMENT_ROOT"] . "/" . EVENT_FILE, "a")
    or die("<span class='error'>ERROR: Couldn't open events file to write event.</span>");

    @fputs($fp, "$Month $Day $Year\r\n$Name\r\n$Desc\r\n")
    or die("<span class='error'>ERROR: Couldn't write to events file.</span>");

    @fclose($fp);


    Deleting an event
    As you may've noticed in the screenshot above, each event is displayed with a "Remove" link beneath it. This link calls cal.php with the details of the post to be deleted.

    The DelPost function handles the deletion of an event, but because we're working with a file, we read all events in and then only write-out the ones that aren't marked for deletion by calling the AddPost function. We do this by comparing the selected event with all events in the events file:

    for($i = 0; $i < sizeof($arrEvents); $i+=3)
    {
    if(!($arrEvents[$i] == $EventDate && $arrEvents[$i+1] == $Name && $arrEvents[$i+2] == $Desc))
    {
    // This entry hasn't been chosen to be deleted.
    // We will add it back to the events
    if($arrEvents[$i+1] != "" && $arrEvents[$i+2] != "")
    {
    // Start by getting the date of the post
    $thisDate = explode(" ", $arrEvents[$i]);
    AddPost($thisDate[1], $thisDate[0], $thisDate[2], $arrEvents[$i+1], $arrEvents[$i+2]);
    }
    }
    }

    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 1 Hosted by Hostway
    Stay green...Green IT