Creating Calendars in PHP – Part 2

In this tutorial we look at the advantages of removing HTML attributes from the PHP code and replacing them with CSS classes, so that the whole dynamically-produced calendar can be restyled just by changing the CSS styles and without having to change the code in any way.

We then look at the MySQL datetime field format which stores a date and time in a format which can be easily changed into a timestamp using the MySQL UNIX_TIMESTAMP() command. We look at the advantages of using the Unix timestamp format, such as making it easy to select dates using simple numerical operators and being able to automatically sort records in order of date and time.

Finally we learn how to select all events that fall on a certain date, and then at how to find all records which fall between a range of dates.

Please note that this article forms part of a chapter in the DMXzone e-book PHP Web Applications for Dreamweaver: Juicy Solutions for the Busy Developer.

 

$2.89
- OR -

Overview

Table of Content:

  • Styling the Calendar
  • Stripping down the HTML
  • Creating the CSS Style Sheet
  • Attaching the Style Sheet to your PHP Page
  • Creating alternate colours for the Date Cells
  • Example Output
  • Working with Dates with MYSQL
  • Creating the Database Table
    • Database Table
    • MySQL command to create Table
  • Adding some example data
  • The MySQL UNIX_TIMESTAMP() command
  • Finding all events on a Specific Day
  • Finding all events between Two Dates
  • Summary

Gareth Downes-Powell

Gareth Downes-PowellGareth has a range of skills, covering many computer and internet related subjects. He is proficient in many different languages including ASP and PHP, and is responsible for the setup and maintenance of both Windows and Linux servers on a daily basis.


In his daily web development work he uses the complete range of Macromedia software, including Dreamweaver MX, Flash MX, Fireworks MX and Director to build a number of websites and applications. Gareth has a close relationship with Macromedia, and as a member of Team Macromedia Dreamweaver, he has worked closely in the development of Dreamweaver, and was a beta tester for Dreamweaver MX.


On a daily basis he provides support for users in the Macromedia forums, answering questions and providing help on a range of different web related subjects. He has also written a number of free and commercial extensions for Dreamweaver MX, to further extend its capabilities using its native JavaScript API’s or C++.


As a web host, Gareth has worked with a range of different servers and operating systems, with the Linux OS as his personal favourite. Most of his development work is done using a combination of Linux, Apache and MySQL and he has written extensively about setting up this type of system, and also running Apache and MySQL under Windows.

See All Postings From Gareth Downes-Powell >>

Reviews

Be the first to write a review

You must me logged in to write a review.