Maybe it would have been more clear if I had my whole code instead of just that partial table row that I needed help on. I've created the calendar already. I just wanted to add additional row to that calendar that I can click to open up new calendar by year and month.
If you can open this php on a browser, you'll notice the links below the calendar in three columns.
Left column is the link to open previous year from whatever the year is currently displayed.
Right column is the link to open next year from whatever the year is currently displayed.
Center column is the links to each month from January thru December, whichever month is clicked, it will open that month calendar from whichever the year is "currently" displayed.
I hope this is more clear. I appologize for any confusion.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>test</title>
<link rel="stylesheet" type="text/css" href="calendar.css" />
</head>
<body><center>
<?php
$date = time();
$Month = date('m', $date);
$Day = date('d', $date);
$Year = date('Y', $date);
/* Calendar layout*/
function calendar_layout($month,$day,$year)
{
/* This checkdate function displays "bool(true)" in the web page, so I commented out */
// var_dump(checkdate($month,$day,$year));
$MonthArray = array("January ","February ","March ","April ","May ","June ","July ","August ","September ","October ","Novembe r","December ");
$ThisMonth = $MonthArray[$month-1];
/* Creates table for calendar */
$Calendar = '<table border="1" cellpadding="5">';
$Header = array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
/* Creates the first row print the Month and Year of this calendar */
$Calendar.= '<tr><td colspan="7">';
$Calendar.= '<div class="largewords">'.$ThisMonth.''.$year.'</div>';
$Calendar.= '</td></tr>';
/* Creates the second row for Week days and print the week days header */
$Calendar.= '<tr>
<td class="weekdays">'.implode('</td><td class="weekdays">',$Header).'</td>
</tr>';
/* Finds out and set how many blank days before 1st day */
$FirstDay = mktime(0,0,0,$month, 1, $year);
$DayOfWeek = date('D', $FirstDay);
switch($DayOfWeek){
case "Sun": $BlankDays = 0; break;
case "Mon": $BlankDays = 1; break;
case "Tue": $BlankDays = 2; break;
case "Wed": $BlankDays = 3; break;
case "Thu": $BlankDays = 4; break;
case "Fri": $BlankDays = 5; break;
case "Sat": $BlankDays = 6; break;
}
/* Finds out how many total days this month */
$DayInMonth = date('t',mktime(0,0,0,$month,1,$year));
$DayCounter = 0;
/* Creates the second row for first week */
$Calendar.= '<tr>';
/* Prints the blank spaces before day 1 */
while($DayCounter < $BlankDays)
{
$Calendar.= '<td> </td>';
$DayCounter++;
}
/* Starts printing dates */
for($PrintDay = 1; $PrintDay <= $DayInMonth; $PrintDay++):
$Calendar.= '<td class="eachday">';
$Calendar.= '<div class="numericdays">'.$PrintDay.'</div>';
$Calendar.= str_repeat('<p> </p>',2);
$Calendar.= '</td>';
if($BlankDays == 6):
$Calendar.= '</tr>';
if(($DayCounter+1) != $DayInMonth):
$Calendar.= '<tr>';
endif;
$BlankDays = -1;
$DayInWeek = 0;
endif;
$DayInWeek++; $BlankDays++; $DayCounter++;
endfor;
/* Prints blank spaces after the last day of the month */
if($DayInWeek < 8):
for($x = 1; $x <= (8 - $DayInWeek); $x++):
$Calendar.= '<td> </td>';
endfor;
endif;
/* Bottom row - links for other years and months */
$LastYear = getDate(mktime(0, 0, 0, $month, 1, $year-1));
$ThisYear = getDate(mktime(0, 0, 0, $month, 1, $year));
$NextYear = getDate(mktime(0, 0, 0, $month, 1, $year+1));
$LastY = $LastYear["year"];
$ThisY = $ThisYear["year"];
$NextY = $NextYear["year"];
/* Initializing the years range from 1970 to 2038 */
$MinYear = date("Y",mktime(0,0,0,1,1,1970));
$MaxYear = date("Y",mktime(0,0,0,1,1,2038));
$Calendar.= "</tr><tr><td>"."<a "."href=\"".$_SERVER["PHP_SELF"]."?year=" . $LastYear["year"] ."\"> $LastY </a></td>\n";
$Calendar.= "<td colspan=\"5\">"."<a "."href=\"".$_SERVER["PHP_SELF"]."?year=".$ThisYear["year"]."&month=" . $MonthArray[0] ."\">Jan.</a> |
"."<a "."href=\"".$_SERVER["PHP_SELF"]."?year=".$ThisYear["year"]."&month=" . $MonthArray[1] ."\">Feb.</a> |
"."<a "."href=\"".$_SERVER["PHP_SELF"]."?year=".$ThisYear["year"]."&month=" . $MonthArray[2] ."\">Mar.</a> |
"."<a "."href=\"".$_SERVER["PHP_SELF"]."?year=".$ThisYear["year"]."&month=" . $MonthArray[3] ."\">Apr.</a> |
"."<a "."href=\"".$_SERVER["PHP_SELF"]."?year=".$ThisYear["year"]."&month=" . $MonthArray[4] ."\">May</a> |
"."<a "."href=\"".$_SERVER["PHP_SELF"]."?year=".$ThisYear["year"]."&month=" . $MonthArray[5] ."\">Jun.</a> |
"."<a "."href=\"".$_SERVER["PHP_SELF"]."?year=".$ThisYear["year"]."&month=" . $MonthArray[6] ."\">Jul.</a> |
"."<a "."href=\"".$_SERVER["PHP_SELF"]."?year=".$ThisYear["year"]."&month=" . $MonthArray[7] ."\">Aug.</a> |
"."<a "."href=\"".$_SERVER["PHP_SELF"]."?year=".$ThisYear["year"]."&month=" . $MonthArray[8] ."\">Sep.</a> |
"."<a "."href=\"".$_SERVER["PHP_SELF"]."?year=".$ThisYear["year"]."&month=" . $MonthArray[9] ."\">Oct.</a> |
"."<a "."href=\"".$_SERVER["PHP_SELF"]."?year=".$ThisYear["year"]."&month=" . $MonthArray[10] ."\">Nov.</a> |
"."<a "."href=\"".$_SERVER["PHP_SELF"]."?year=".$ThisYear["year"]."&month=" . $MonthArray[11] ."\">Dec.</a>
</td>";
$Calendar.= "<td>"."<a "."href=\"".$_SERVER["PHP_SELF"]."?year=" . $NextYear["year"] ."\"> $NextY </a></td>\n";
}
/* Close the table */
$Calendar.= '</tr></table>';
return $Calendar;
}
echo '<a href="index.php">Today</a>', ' is: ', date('l, F jS Y');
echo "<br />";
echo "<br />";
echo calendar_layout("$Month","$Day","$Year");
?>
</center>
</body>
</html>
and while I was looking through that site that Leo posted, I've found out something.
If I understood correctly, the logic is to code to check whether $Month & $Year variables are set or not for this particular section.
So I found this if statment:
if(isset($_GET["Year"]))
{
use local system's year
}
else
{
$Year = $_GET["Year"]
}
Now the problem is...how to figure out the syntax and apply it to my original code?