MIKESTOWE.COM

you are here

Super Simple Calendar

Here is a quick, table based PHP calendar script. Pretty simple, and should be fairly easy to modify and style as you see fit :)

<?php
$month 
= (isset($_GET['month'])?$_GET['month']:date("n"));
$year = (isset($_GET['year'])?$_GET['year']:date("Y"));
$time mktime(0,0,0,$month,1,$year);

$numberofdays date("t",$time);
$monthname date("F",$time);
$start date("N",$time);


// create header
echo <<<HEADER
<style type="text/css">body { font-family: arial; color: #333; text-align: center; } #day { border-left: 1px solid #333; border-bottom: 1px solid #333; height: 15px; width: 15px; padding: 5px; display: block; } td { background: #fff; width: 100px; height: 100px; border: 1px solid #333; } #header td { text-align: center; height: 30px; font-weight: bold; }</style>
<h1>
$monthname $year</h1><table align="center"><tr id="header"><td>Monday</td><td>Tuesday</td><td>Wednesday</td><td>Thursday</td><td>Friday</td><td>Saturday</td><td>Sunday</td></tr>
<tr>
HEADER;

if(
$start 1) {
echo 
'<td colspan="'.($start-1).'" style="background: #333;">&nbsp;</td>';
}

$j $start;
for(
$i=1$i <= $numberofdays$i++) {
    echo 
'<td valign="top" align="right"><div id="day">'.$i.'</div></td>';
    
$j++;
    if(
$j == && $i != $numberofdays) {
        echo 
'</tr><tr>';
        
$j 1;
    }
}
echo 
'</tr></table>';
?>
Share this Page:
Facebook Twitter Linkedin Reddit Tumblr Email

Leave a Reply

Your email address will not be published. Required fields are marked *