When you search from google for php calendar you will get lot of free and comercial script for this purpose. But my problem is that all those php calendar script is hard to implement and to modify. So I decided to create my own simple calendar script, and share to those who are looking for this kind of script and want to modify it.
PHP Code:
$x=$_GET[x];
if($x=="") $x = date("n");
$date = strtotime("2006/$x/1");
$day = date("D",$date);
$m = date("F",$date);
$totaldays = date("t",$date); //get the total day of specified date
echo "<table border = '1' cellspacing = '0' bordercolor='blue' cellpadding ='2'><tr>
<td colspan='7'>$m</td></tr>
<tr>
<td><font size = '1' face = 'tahoma'>Sun</font></td>
<td><font size = '1' face = 'tahoma'>Mon</font></td>
<td><font size = '1' face = 'tahoma'>Tue</font></td>
<td><font size = '1' face = 'tahoma'>Wed</font></td>
<td><font size = '1' face = 'tahoma'>Thu</font></td>
<td><font size = '1' face = 'tahoma'>Fri</font></td>
<td><font size = '1' face = 'tahoma'>Sat</font></td>
</tr>
";
if($day=="Sun") $st=1;
if($day=="Mon") $st=2;
if($day=="Tue") $st=3;
if($day=="Wed") $st=4;
if($day=="Thu") $st=5;
if($day=="Fri") $st=6;
if($day=="Sat") $st=7;
if ($st >= 6 && $totaldays == 31) {
$tl=42;
}elseif($st == 7 && $totaldays == 30){
$tl = 42;
}else{
$tl = 35;
}
$ctr = 1;
$d=1;
for($i=1;$i<=$tl;$i++){
if($ctr==1) echo "<tr>";
if($i >= $st && $d <= $totaldays){
echo "<td align='center'><font size = '2' face = 'tahoma'>$d</font></td>";
$d++;
}
else{
echo "<td> </td>";
}
$ctr++;
if($ctr > 7) {
$ctr=1;
echo "</tr>";
}
}
$prev=$x - 1;
$next = $x + 1;
if($prev==0) $prev=1;
if($next==13) $next = 12;
echo "</table><b><a href = 'calendar.php?x=$prev'>Previous</a> <a href = 'calendar.php?x=$next'>Next</a></b>";