Easy Design Internet Info
Welcome to Easy Design Internet Info!

Internet Articles


Simple & Free Website Calendar
By Jeremy Miller


Offering a calendar to your site is a popular and easy addition to any site. In this article I will explain the relatively simple logic to allow you to create your own calendar. To be more specific, we`ll create a calendar which shows either a monthly or weekly view and assume you can pass variables into the program.

The first thing needed are the minimum variables or parameters necessary to give ourselves a fair amount of flexibility. These variables will be the starting day, number of days to show, and any offset needed. The first two variables are pretty obvious, but the purpose of offset may not be clear. offset can be used to show previous and next calendars while maintaining view (e.g. monthly or weekly).

Next, considering that we would like to be able to show periods such as "this week", "this month", "next week", etc. we will need to create some logic to handle these options. To do this, we`ll have 3 variables the program will accept: calendar, showdays, & offset. calendar will be used to request a specific calendar (e.g. "this week") while the other two variables come from those defined above. Our script will need to take the calendar and offset variables to populate the starting day. Note: All code shown here is pseudo-code and will not work in any known language. For the example calendar script in PHP, please visit the author`s site.

// First, establish the starting day and number of days to show.
// Express number of days using "month" for a monthly show because months vary in number of days.

IF calendar = "this month"
start_day = first of the month
num_days = "month"
ELSE IF calendar = "this week"
start_day = last Sunday
num_days = 7
ELSE IF
... continue for all acceptable forms
ELSE
start_day = default day
num_days = default number
END IF

// Now modify start_day by the appropriate offset and establish number of days (count_max) to
// show appropriate for the value of num_days
IF num_days = "month"
start_day = first of the month adjusted by offset number of months
count_max = number of days in the month
ELSE
start_day = start_day adjusted by offset number of days
count_max = num_days
END IF

// Determine the day of the week start_day falls on
start_day_of_week = day of week for start_day, this should be a number from 0 to 6.

We have now collected all the information necessary to show the appropriate calendar. Moving on, we now need to generate our calendar. Our calendar should output the header information and the name of the month as a caption. Then all which remains is to output each row. Let`s take a look at how that can be achieved:

column_position = start_day_of_week

IF column_position > 0
OUTPUT: empty TD cell spanning column_position+1 cells
INCREMENT: column_position
END IF

original_start_day = start_day

current_day = start_day

WHILE (current_day - start_day) < count_max)
IF (column_position MOD 7) = 0
OUTPUT: open TR tag
END IF
OUTPUT: TD cell with current_day in it
INCREMENT: column_position
INCREMENT: current_day
IF (column_position MOD 7) = 0
OUTPUT: close TR tag
END IF
END WHILE

This will output each of the rows, wrapping on Saturday, but will leave the last TR tag open, so be sure to close it and the table. Then, all you need to do is save your file and use the code, setting the appropriate variables, wherever you would like! Now, this is an extremely simple example and adding features such as navigation and event management are definite pluses. For a copy of this script with functioning code, please see the author`s website.

For more information about this article and/or the author visit http://www.script-reference.com/

For more information, news and articles see:

Website Design York - Website Design York
...He has wanted to get into website design Yorkfor a long time but he always felt that no decent firm would look at him because he did not have enough experience. However, although he is lacking in exp...
Visit Website Design York...

Clive Roberts - Clive Roberts
...ole was to develop the invoice generation and notification for British Airways. Which used SQL2005 (tables, stored procedures, triggers); Reporting Services for the invoices; Notification service to s...
Visit Clive Roberts...

Web Design Harrogate - Web Design Harrogate
... a new job in web design harrogate. She has been looking for a new job doing web design harrogatefor some time now and she considers herself really lucky to have found the perfect job. She is obviou...
Visit Web Design Harrogate...

Advertising Agency Bristol - Advertising Agency Bristol
...Most companies recognise the need to promote their goods and materials otherwise sales would slump and the business could be in trouble. An effective advertising campaign can work wonders for the hea...
Visit Advertising Agency Bristol...

Design Agency Manchester - Design Agency Manchester
...gn agency manchester has served you proud for the past 2 years and when you first started up in business it was just what you needed to give you an immediate online presence. That was then and this i...
Visit Design Agency Manchester...

Web Design Manchester - Web Design Manchester
...ly as possible so that sales can quickly take an upward spiral. Making your presence felt isn`t always that easy though and a great place to start will be your company`s website. As a startup busines...
Visit Web Design Manchester...

Software Engineer - Software Engineer
...re Engineer covers all phases of software development, support and management and particularly focuses on a methodical approach to the error-free design and building of software. A Software Engineer w...
Visit Software Engineer...

Website Design Bristol - Website Design Bristol
...ey lack a certain web presence? Has the site looked the same for the best part of a decade and could you be found guilty of not moving with the times? You could be dong your company a massive injusti...
Visit Website Design Bristol...


Click For More Detailed Information on:
your good science ::big study store ::easy technoloical to you ::technological online ::best apple store

Home  |  About Us  |  Contact Us  |  Articles  |  Special Reports  |  Links  |  Site Map

Copyright © 2003-2010. All Rights Reserved.


Valid CSS!