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
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
Mobile Dev World

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 : 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 Update Picture
Christopher Ostmo
Date : Sep 03rd 1998
Grade : 3 of 5 (graded 51 times)
Viewed : 56594
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Christopher Ostmo
Action : Grade This Code Example
Tools : My Examples List

  Submit your own code examples 
 

<?
/* This calendar is not very pretty as-is, but it is functional and fast.
Formatting to suit your needs should be fairly simple.

The latest version of this calendar is formatted much more niceley. It
also includes a full-featured "Community Calendar" which is linked to a
MySQL database for reporting upcoming events.

The latest copy of the calendar can be viewed and/or downloaded from:
http://modems.rosenet.net/mysql/ */

/* Set some variables */
$date=01;
$day=01;
$off=0;

/* The month and year variables can (should) be passed from a preceding
web page rather than hard coded */
$month = '05';
$year = '1999';

/* Figure out how many days are in this month */
while (checkdate($month,$date,$year)):
$date++;
endwhile;

/* Create a table with days of the week headers */
echo "<table border='1' cellpaddig='5' cellspacing='5' width='100%'><tr>";
echo "<th><b><font face='Arial'>Sunday</font></b></th>";
echo "<th><b><font face='Arial'>Monday</font></b></th>";
echo "<th><b><font face='Arial'>Tuesday</font></b></th>";
echo "<th><b><font face='Arial'>Wednesday</font></b></th>";
echo "<th><b><font face='Arial'>Thursday</font></b></th>";
echo "<th><b><font face='Arial'>Friday</font></b></th>";
echo "<th><b><font face='Arial'>Saturday</font></b></th>";

/* Start the table data and make sure the number of days does not exceed
the total for the month - $date will always be one more than the total
number of days in the momth */
echo "<tr>";
while ($day<$date):

/* Figure what day of the week the first falls on and set the number of
preceding and trailing cells accordingly */
if ($day == '01' and date('l', mktime(0,0,0,$month,$day,$year)) == 'Sunday') {
echo "<td>$day</td>";
$off = '01';
}
elseif ($day == '01' and date('l', mktime(0,0,0,$month,$day,$year)) ==
'Monday') {
echo "<td></td><td>$day</td>";
$off= '02';
}
elseif ($day == '01' and date('l', mktime(0,0,0,$month,$day,$year)) ==
'Tuesday') {
echo "<td></td><td></td><td>$day</td>";
$off= '03';
}
elseif ($day == '01' and date('l', mktime(0,0,0,$month,$day,$year)) ==
'Wednesday') {
echo "<td></td><td></td><td></td><td>$day</td>";
$off= '04';
}
elseif ($day == '01' and date('l', mktime(0,0,0,$month,$day,$year)) ==
'Thursday') {
echo "<td></td><td></td><td></td><td></td><td>$day</td>";
$off= '05';
}
elseif ($day == '01' and date('l', mktime(0,0,0,$month,$day,$year)) ==
'Friday') {
echo "<td></td><td></td><td></td><td></td><td></td><td>$day</td>";
$off= '06';
}
elseif ($day == '01' and date('l', mktime(0,0,0,$month,$day,$year)) ==
'Saturday') {
echo "<td></td><td></td><td></td><td></td><td></td><td></td><td>$day</td>";
$off= '07';
}
else {
echo "<td>$day</td>";
}

/* Increment the day and increment the cells that go before the end of the row
and end the row when appropriate */
$day++;
$off++;

if ($off>7) {
echo "</tr><tr>";
$off='01';
} else {
echo "";
}

endwhile;

echo "</table>";

/*
This script was created by Rosenet, Inc. 1998. Feel free to use and modify it.
If you use this script, please do not alter or remove this comment section.
http://www.rosenet.net/
http://modems.rosenet.net/
http://modems.rosenet.net/mysql/
*/
?>



Calendar class on the same page , suitable for reservation
Categories : PHP, Calendar, Date Time
CALENDAR - easy calendar-navigation with PHP
Categories : PHP, Date Time, HTML and PHP, Calendar
Count how many weeks in the month have a specified day, such as Mon, Tue, etc. Var avail - number of days - first day name of the month, occurrences of Sun, occurrences of Mon, etc. Allows you to calculate number of working hours exclude Holidays.
Categories : Calendar, Date Time, PHP, Databases, MySQL
Simple PHP control CSS Calendar
Categories : PHP, HTML and PHP, Calendar, Date Time, CSS
This code consists of two parts, the first part is a .html file that uses a form to pass 3 date variables into day_of_week.php3 You input the mm/dd/yyyy of the day then it prints what day of the week that day falls on.
Categories : Date Time, PHP, Complete Programs
Web Self Service Resource Scheduler Using Session Variables under php4 includes Calendar building code - requires MySQL
Categories : PHP, Complete Programs, Calendar, MySQL, Databases
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
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
enhanced date picker with jcript checking for a dynamic date input
Categories : PHP, Java Script, Date Time, Calendar, Arrays
table calendar pretty much does what cal(1) does - prints out a calendar.
Categories : Date Time, PHP, Calendar
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
Calendars to choose a range of dates , reservation events ...
Categories : PHP, Calendar, Java Script, Date Time
Example of using the pcCalendar class, article 1468 on weberdev.com. Calendar example.
Categories : PHP, Date Time, PHP Classes, Calendar
Customizable Calendar Class
Categories : HTML and PHP, Date Time, PHP, PHP Classes, Calendar
function to generate calendars on the fly.
Categories : Calendar, PHP, Date Time