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
Submit Site
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 : function to generate calendars on the fly.
Categories : Calendar, PHP, Date Time Update Picture
James Whiddon
Date : Dec 01st 1999
Grade : 2 of 5 (graded 5 times)
Viewed : 14310
File : No file for this code example.
Images : No Images for this code example.
Search : More code by James Whiddon
Action : Grade This Code Example
Tools : My Examples List

  Submit your own code examples 
 

<?

function makecal($stmonth, $styear) {

###################################
## define variables-little cleaner
## than mucking over the code to
## change stuff
##

$face = "verdana"; ## font face for all text
$size = "1"; ## font size for all text
$height = "22"; ## cell height
$width = "22"; ## cell width
$todaycolor = "#CC0000"; ## font color for the current date
$inmonthface = "#000000"; ## font color for days in the display month
$outmonthface = "#666666"; ## font color for days not in the display month
$inbgcolor = "#FFFFCC"; ## cell bgcolor for days in the display month
$outbgcolor = "#FFCCFF"; ## cell bgcolor for days not in display month

###################################
## make workie code stuph
##

$stdate = mktime(0,0,0,$stmonth,1,$styear);
$startdate = $currdate = mktime(0,0,0,$stmonth,1 - date("w", mktime(0,0,0,$stmonth,1,$styear)),$styear);
$enddate = mktime(0,0,0,date("m",$stdate) + 1,7 - date("w", mktime(0,0,0,$stmonth + 1,0,$styear)),$styear);

echo "<table border=1 cellpadding=1 cellspacing=0>\n";
echo "<tr>\n<th colspan=7 height=\"$height\"><font face=\"$face\" size=\"$size\">" . date("F",$stdate) . " " . date
("Y",$stdate) . "</th>\n</tr>\n";
echo "<tr>\n<th width=\"$width\" height=\"$height\" valign=\"middle\" align=\"center\"><font face=\"$face\"
size=\"$size\">Su</th>\n";
echo "<th width=\"$width\" height=\"$height\" valign=\"middle\" align=\"center\"><font face=\"$face\"
size=\"$size\">Mo</th>\n";
echo "<th width=\"$width\" height=\"$height\" valign=\"middle\" align=\"center\"><font face=\"$face\"
size=\"$size\">Tu</th>\n";
echo "<th width=\"$width\" height=\"$height\" valign=\"middle\" align=\"center\"><font face=\"$face\"
size=\"$size\">We</th>\n";
echo "<th width=\"$width\" height=\"$height\" valign=\"middle\" align=\"center\"><font face=\"$face\"
size=\"$size\">Th</th>\n";
echo "<th width=\"$width\" height=\"$height\" valign=\"middle\" align=\"center\"><font face=\"$face\"
size=\"$size\">Fr</th>\n";
echo "<th width=\"$width\" height=\"$height\" valign=\"middle\" align=\"center\"><font face=\"$face\"
size=\"$size\">Sa</th>\n</tr>\n";

$i=0;
while ($currdate < $enddate) {
echo "<tr>\n";
for ($c = 0; $c < 7; $c++) {
if (date("m",$stdate) == date("m",$currdate)) {
$bgcolor = $inbgcolor;
} else {
$bgcolor = $outbgcolor;
}
if (date("d",$currdate) == date("d") && date("m",$currdate) == date("m") && date("Y",$currdate) == date
("Y")) {
$fcolor = $todaycolor;
} elseif (date("m",$currdate) == date("m",$stdate) && date("Y",$currdate) == date("Y",$stdate)) {
$fcolor = $inmonthface;
} else {
$fcolor = $outmonthface;
}
echo "<td align=\"center\" height=\"$height\" width=\"$width\" valign=\"middle\" bgcolor=\"$bgcolor\"><font
face=\"$face\" size=\"$size\"
color=\"$fcolor\">";
echo date ("j",$currdate);
echo "</font></td>\n";
$i++;
$currdate = mktime(0,0,0,date("m",$startdate),date("d",$startdate) + $i,date("Y",$startdate));
}
echo "</tr>\n";
}
echo "</table>";

}

###################################
## example usage
##

echo "<html><head></head><body bgcolor=\"#ffffff\">\n\n";
echo "<form action=cal.php3 method=post>\n";
echo "<select name=stmonth>\n";
echo "<option>1\n";
echo "<option>2\n";
echo "<option>3\n";
echo "<option>4\n";
echo "<option>5\n";
echo "<option>6\n";
echo "<option>7\n";
echo "<option>8\n";
echo "<option>9\n";
echo "<option>10\n";
echo "<option>11\n";
echo "<option>12\n";
echo "</select>\n";
echo "<select name=styear>\n";
echo "<option>1999\n";
echo "<option>2000\n";
echo "<option>2001\n";
echo "<option>2002\n";
echo "<option>2003\n";
echo "<option>2029\n";
echo "</select>\n";
echo "<input type=submit value=\"show cal\">\n<input type=submit name=source value=\"view source\">\n</form>\n\n";
echo "<BR>\n\n";

if ($stmonth && $styear && empty($source)) {
echo makecal($stmonth,$styear);
} elseif (empty($source)) {
echo makecal(date("m"),date("Y"));
} else {
echo "<code><font size=1>\n";
show_source("cal.php3");
echo "</font></code>\n";
}

echo "</body>\n</html>";

?>




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
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
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
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
Calendars to choose a range of dates , reservation events ...
Categories : PHP, Calendar, Java Script, Date Time
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
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
Simple PHP control CSS Calender
Categories : PHP, HTML and PHP, Calendar, Date Time, CSS
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
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
 James Whiddon wrote : 169
oops.  i forgot to add the \ before the " starting at line
32 after the $face variable.  sorry.    
 
 Paul Meagher wrote : 280
This calender does not appear to work correctly as of 
March 2000.  Might be some type of leap year problem.
 
 Buddy Fortner wrote : 293
I can`t get it to work either.  should it copy and paste 
"as is", or is there some edits to make?
 
 James Whiddon wrote : 374
What types of problems are you having?  It seems to be working on my 
machine.
 
 Rod wrote : 385
Where is cal.php3??????

 
 pierre-yves lemaire wrote : 429
It does not work after march 2000, Did someone find 
out the problem ?

It keeps giving me january of 1999 when I try anything 
after march 2000.

py
 
 Dimitrios Zinas wrote :830
It works ok just the list writes 1999.
If you want update e-mailme...