WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDES  |  PHP CLASSES  |  CODE SEARCH  |  ARTICLES SEARCH  |  PHP FORUMS  |  PHP MANUAL  |  PHP FUNCTIONS LIST  |  WEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
WeberDev's Monthly code contest PHP Code Contest
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Index
PHP Web Logs (BLogs)
Web Development Resources
Web Development Content
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
Forex Trading Online forex trading platform

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : table calendar pretty much does what cal(1) does - prints out a calendar.
Categories : Date Time, PHP, Calendar Update Picture
Peter Norton
Date : Jan 17th 1999
Grade : 5 of 5 (graded 2 times)
Viewed : 3705
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Peter Norton
Action : Grade This Code Example
Tools : My Examples List

  Submit your own code examples 
 

table calendar pretty much does what cal(1) does - prints out a calendar.
It has some other options, and when I've gotten a better idea of the php
OO syntax, I'll make this into a class that can be accessed more convenienty.
I'm currently using this in a system that has no graphics, but I want hooks
to make graphics available for element of the table, with an ALT tag for
text browsers. have fun, send suggestions, questions, etc to spacey@pobox.com


<!-- I should add something in here to highlight "today" if it's in the scope of the viewed month -->
<!-- -PN 3/30/1998 -->
<?
# $selected{Month,Day,Year} should be set by the calling script.
# Actually, I should turn this into a function/object, and call it with
# those values. That would sanatize the calling script. Too many
# variables crawling about already.
# Create an html calendar for a month.
if (!$selectedDay ) {
$selectedDay = date( 'd');
}
if (!$selectedMonth) {
$selectedMonth = date( 'm');
}
if (!$selectedYear) {
$selectedYear = date( 'Y');
}

# get the first day of the week!
$firstday = date( 'w',mktime(0,0,0,$selectedMonth,1,$selectedYear));

# have to perform a loop to test from 31 backwards using this
# to see which is the last day of the month
$lastday = 31;
do {
# *Sigh* recursion would have been more fun here.
$monthOrig = date( 'm',mktime(0,0,0,$selectedMonth,1,$selectedYear));
$monthTest = date( 'm',mktime(0,0,0,$selectedMonth,$lastday,$selectedYear));
if ($monthTest != $monthOrig) { $lastday -= 1; }
} while ($monthTest != $monthOrig);

$monthName = date( 'F',mktime(0,0,0,$selectedMonth,1,$selectedYear));

if($DEBUGGING_SET) {
print( "<p>first day of the first week of $selectedMonth $selectedYear is $firstday (from 0 to 6) <p>\n");
print( "The last day of $selectedMonth $selectedYear is $lastday\n<p>");
}

$days[0] = 'Sun';
$days[1] = 'Mon';
$days[2] = 'Tue';
$days[3] = 'Wed';
$days[4] = 'Thu';
$days[5] = 'Fri';
$days[6] = 'Sat';

$dayRow = 0;
print( "<table bgcolor=\"#FFFFFF\">");
print( "<caption valign=\"center\"><b>$monthName $selectedYear</b></caption>");
print( "<tr>\n");
for($i=0; $i<=6; $i++) {
print( "<td width=10%>$days[$i]</td>\n");
}
print( "</tr>\n");

print( "<tr>\n");
while($dayRow < $firstday) {
print( "<td><!-- This day in last month --></td>");
$dayRow += 1;
}

$day = 0;
if($frametarget) {
$targetString = 'target = '.$frametarget;
} else {
$targetString = '';
}

while($day < $lastday) {
if(($dayRow % 7) == 0) {
print( "</tr>\n<tr>\n");
}
$adjusted_day = $day+1;
print( "<td><a href=\"/php3/eventCalendar/event_content.phtml?
month=$selectedMonth&day=$adjusted_day&year=$selectedYear\" $targetString>$adjusted_day</a></td>");
$day += 1;
$dayRow += 1;
}
print( "\n</tr>\n</table>\n");
# print("$selectedMonth");
?>



Calendar using Date function
Categories : HTML and PHP, PHP, Date Time, Calendar
A simple and fast calendar combining PHP and tables. Use this as a base for applications in which a calendar is needed.
Categories : Date Time, PHP, Complete Programs, Calendar
A PHP Calendar function with CSS : add a cool calendar to any php page by just adding a calendar class based function.
Categories : PHP, PHP Classes, Calendar, Date Time
pcCalendar class - Allows for the creation of calendars in HTML pages. All output functions can be easily overridden, refer to article 1471 for an example.
Categories : PHP, Date Time, Calendar, PHP Classes
Monthly and Daily Upcoming Events calendar.
Categories : Date Time, PostgreSQL, PHP, Calendar, Databases
Example of using the pcCalendar class, article 1468 on weberdev.com. Calendar example.
Categories : PHP, Date Time, PHP Classes, Calendar
Functions used to define a schedule of holidays. Can define non-fixed holidays (eg. 3rd sunday of June).
Categories : Calendar, Date Time, PHP
CALENDAR - easy calendar-navigation with PHP
Categories : PHP, Date Time, HTML and PHP, Calendar
Calendars to choose a range of dates , reservation events ...
Categories : PHP, Calendar, Java Script, Date Time
This script contains 2 functions: 1 to create html select object based on your own customer date format entry- "M d Y h:i.... etc". The second function processes the select object on submit back to unix time.
Categories : PHP, Calendar, Date Time, HTML and PHP
Shows the current time as a PNG-image. This script does not use the GD library. You can use it as a benchmark (because it's slow), or as a quick reference for implementing a simple PNG-file generator.
Categories : Graphics, Zlib, Calendar, PHP, Date Time
Simple PHP control CSS Calender
Categories : PHP, HTML and PHP, Calendar, Date Time, CSS
enhanced date picker with jcript checking for a dynamic date input
Categories : PHP, Java Script, Date Time, Calendar, Arrays
Calendar, Kalender, date, time, day, month, year
Categories : PHP, Date Time, Calendar
Calendar class on the same page , suitable for reservation
Categories : PHP, Calendar, Date Time