Code for Calendar with browsing and jumping

Authors

Part of My PHP Portfolio

<html><head>
<title>Web and Database Designs of Santa Cruz - Month Browser Calendar</title>
</head>
<?php
/* Copyright March 2010 by Will Johnson, wjhonson@aol.com
Web and Database Designs of Santa Cruz, All Rights Reserved */ ?>

<body>
<table style="border-color: violet; border-width: 1px; border-collapse: collapse" border="1" bordercolor="violet" cellspacing="0" width="100%"> 
<tr height="60px"><td colspan="3" bgcolor="violet">&nbsp;</td></tr>

<tr><td width="60px" bgcolor="violet">&nbsp;&nbsp;&nbsp;</td>
<td><div style="background-color:ivory"><center><div style="margin-left:25px; margin-right:25px;"><div style="color:navy;font-size:24px">The Month Browser Calendar<br>by Web and Database Designs of Santa Cruz</div><br>
Contact me at <a href = "mailto:wjhonson@aol.com">wjhonson@aol.com</a><br>
<br>
This calendar combines features for jumping directly to a month and year, and also for browsing
backwards and forwards from any chosen month.<br>
<br>

<?php
    include("Generate.php");
/* In the generate_calendar function, the first arg is Year, second arg is Month */
/* the third argument $days is an optional array that can contain information you want to specify for each day, including a location to link that day to, a stylesheet class for that day, and any content you want to appear for that day of the calendar. Each key corresponds to the day of the month, and each value is an array containing one to three elements. The first element is the location you want the day to link to, the second element is a space-separated list of classes (for stylesheets), and the third element is content that you want to appear in that day's cell, instead of just the day's number. */

    $time = time();
    If (is_null($year))
    $year = date('Y', $time);
    If (is_null($month))
    $month = date('n', $time);

    $newMonthNo = $_GET["MonthNo"];
    $newyear = $_GET["Year"];
    $errM=true;
    if (!is_null($newMonthNo))
    if (intval($newMonthNo))
       if ($newMonthNo > 0)
              if ($newMonthNo < 13)
                 {
                $month = $newMonthNo;
                 $errM=false;
                 }
    $errY=true;
    if (!is_null($newyear))
    if (intval($newyear))
       if ($newyear > 1901)
              if ($newyear < 2038)
                 {
             $year = $newyear;
                 $errY=false;
                 }

    echo '<form method = "GET" action = "Monthbrowser.php">';
    echo 'Month Number: <input type = "numeric" name = "MonthNo" value = "'.$month.'">';

    echo 'Year : <input type = "numeric" name = "Year" value = "'.$year.'">';
    echo '<input type = "submit" value = "Go to month">';
    echo '<input type = "Reset" value = "Clear"> </form>';
    if (($errM) or ($errY)) echo 'Input error'; else echo 'Result';

    $prevyear = strftime("%Y",mktime(0,0,0,$month,-1,$year));
    $prevmonth = strftime("%m",mktime(0,0,0,$month,-1,$year));
    $nextyear = strftime("%Y",mktime(0,0,0,$month+1,+1,$year));
    $nextmonth = strftime("%m",mktime(0,0,0,$month+1,+1,$year));

    $prevmonthlink = 'Monthbrowser.php?MonthNo='.$prevmonth.'&Year='.$prevyear;
    $nextmonthlink = 'Monthbrowser.php?MonthNo='.$nextmonth.'&Year='.$nextyear;

    $pn = array('< Prev '=>$prevmonthlink, ' Next >'=>$nextmonthlink);
    echo generate_calendar($year, $month, NULL, 3, Null, 0, $pn);

?>
</center></div></div></div></td>
<td width="60px" bgcolor="violet">&nbsp;&nbsp;&nbsp;</td></tr>
<tr><td colspan="3" bgcolor="violet" height="60px" >&nbsp;</td></tr>
 </table>

</body></html>