web blazonry web development scripts and tutorials
 
Web blazonry.com
   Home       PHP       Name Generators       Perl       CSS       Javascript       Java       devTips       Resources   




PHP Name Generators
  Wu-Name
  U.S. Name
  Baby Name






PHP: Web Calendar With Events

This coding example builds a calendar for the current month. It provides navigation to go backward or forward, month-by-month. Click a date to fill in a form to add an event.

Use the calendar with or without the "add event" feature. Building a calendar on-the-fly without other bells and whistles has its practical uses.

Take a look at the demo of the calendar before we discuss how it works.

Building the Calendar for the Current Month
First generate the calendar for the current month. Grab today's date. Then get the month and year. Create a new date of the first of the month. From this date you can figure out which day of the week it falls on.

Next, figure out the last day of the month. I loop through the days 28th - 32nd and create a new date out of it. Compare the current month to this new date's month. If it changed, the previous day was the last day of the month.

You then start on the first day, postitioning yourself over however many weekdays the first is in. Next, loop through all the days until the day reaches the end of the month. Keep track of the weekdays using modulus 7 to find the end of each week.

More Info About Calendars
PHP has some great date function capabilities such as built-in support for text months and days. Plus, it can even display the appropiate suffix on a day. ('st', 'nd' 'rd', 'th' in 1st, 2nd, 3rd 4th). View the source code and the PHP documentation to see how these functions are used.

I wrote a similar calendar in ASP. You can download the JScript ASP source code for that calendar below. Note it is different than the PHP version shown here.

View Event Calendar Demo


Download PHP Source Here (datemenu_php.phps)

Download ASP Source Here (datemenu_asp.txt)

 

Newest Pages
Free Linux Admin Books
Free Linux Books for Programmers
Free Books for Linux on the Desktop
Free PHP Books
Free JavaScript Books
Free Java Books - Advanced
Free Java Books - Basic
Free Perl Books
Free Python Books
Quote of the Day (PHP)
Debugging Part 2
How to Test Google Ads
Source Code for Test Google Ads (PHP)
Most Popular Pages
U.S. Name Generator
Wu Name Generator
Baby Name Generator
Upload and Resize an Image (PHP)
Popup Windows (JavaScript)
How To Install Apache + PHP + MySQL
Simple Web Calendar (PHP)

Least Popular Pages
Image Load-Order (Javascript)
dHTML: Scrolling Layers
iNews Aplet (Java)
ProcLog Search Your Logs (Perl)
 
 

  © 1997-2007. astonishinc.com   All Rights Reserved.