Calender,in,PHP

Ron 10/11/2016 0

Calender in PHP

PHP
<?PHP 
echo "<html>"; 
echo "<head>"; 
echo "</head>"; 
echo "<body bgcolor=\"#000066\" VLINK = \"#6699cc\">"; 
echo "<P>"; 
echo "<table border=\"1\" cellpadding=\"1\" style=\"border-collapse: collapse\" 
bordercolor=\"#6699cc\" width=\"15%\" id=\"AutoNumber1\">"; 
echo "<TR><TD>"; 
$GoToDay = $HTTP_GET_VARS['txtDay']; 

if(!empty($GoToDay)) 
{ 
        $StartDate=date("m/d/y",strtotime ("$GoToDay")); 

} 
else 
{ 
        if(empty($StartDate)) 
        { 
                $StartDate=date("m/d/y"); 
        } 
} 
                echo WriteMonth($StartDate); 


function WriteMonth($StartDate) 
{ 

        $WriteMonth=""; // for returning the value of the whole string 
        $CurrentDate=date("m/1/y", strtotime ("$StartDate")); //the date of what ever value is 
recieed will be stored here 
        $setMonth=date("m",strtotime ($CurrentDate)); 
        $todaysDate=date("j",strtotime(date("m/d/y")));                //for storing todays date 
        $mmon=date("m",strtotime ($CurrentDate));                //for storing month 
        $myear=date("Y",strtotime ($CurrentDate));                //for storing year 
        $noOfDays=date("t",strtotime ($CurrentDate));        //for storing number of days in a month 




$WriteMonth.=""; 
$WriteMonth.="<table border=\"0\" cellpadding=\"1\" cellspacing=\"1\" width=\"150\" ><tr><td 
colspan=\"2\" valign=top align=\"left\">"; 


$WriteMonth.="<a href=\"left.php?txtDay=".date("m/1/y", strtotime 
("$CurrentDate -1 months"))."\"><font 
color=\"#6699cc\">Prev</font></a></td><td colspan=\"3\" align=\"center\"><a 
href=\"left.php?txtDay=".date("m/1/y", 
strtotime ("$StartDate months"))."\"><b><font color=\"#6699cc\">".date("F",strtotime 
($StartDate))." ".date("Y",strtotime ($StartDate)); 

$WriteMonth.="</font></b> </a></td><td colspan=\"2\" valign=top align=\"right\">"; 

$WriteMonth.="<a href=\"left.php?txtDay=".date("m/1/y", strtotime 
("$StartDate  1 months"))."\"><font 
color=\"#6699cc\">Next</font></a>"; 


$WriteMonth.="</td></tr><tr bgcolor=\"#6699cc\">"; 
$WriteMonth.="<td align='center'><B><font color=\"#000066\">S</font></B></td>"; 
$WriteMonth.="<td align='center'><B><font color=\"#000066\">M</font></B></td>"; 
$WriteMonth.="<td align='center'><B><font color=\"#000066\">T</font></B></td>"; 
$WriteMonth.="<td align='center'><B><font color=\"#000066\">W</font></B></td>"; 
$WriteMonth.="<td align='center'><B><font color=\"#000066\">T</font></B></td>"; 
$WriteMonth.="<td align='center'><B><font color=\"#000066\">F</font></B></td>"; 
$WriteMonth.="<td align='center'><B><font color=\"#000066\">S</font></B></td>"; 
$WriteMonth.="</tr>"; 

$startMonth=date("$myear/$setMonth/01"); 
$endMonth=date("$myear/$setMonth/$noOfDays"); 


$WriteMonth .= "<tr>"; 
for($i=1;$i<=$noOfDays;$i  ) { 
        $coolmonth=date("$setMonth/$i/$myear"); 
        $TBD=date("j",strtotime ($coolmonth)); 
        $BD=date("j",strtotime ($coolmonth)); 
        $BDay=date("D",strtotime ($coolmonth)); 
        if ($todaysDate==$TBD) 
        { 
        $BD= "<B><font color=\"#FFFFFF\">$TBD</font></B>"; 
        } 
        $BD = "<td  align=\"center\" bgcolor = \"#6699cc\"><font color=\"#000066\">$BD</font></td>"; 

        switch($BDay){ 
                        case 'Sun': 
                                        $WriteMonth .= "$BD"; 
                                break; 
                        case 'Mon': 
                                if($TBD==1) 
                                        $WriteMonth .= "<td> </td>"; 
                                        $WriteMonth .= "$BD"; 
                                break; 
                        case 'Tue': 
                                if($TBD==1) 
                                        $WriteMonth .= "<td> </td><td> </td>"; 
                                $WriteMonth .= "$BD"; 
                                        break; 
                        case 'Wed': 
                                if($TBD==1) 
                                         
$WriteMonth .= "<td> </td><td> </td><td> </td>"; 
                                $WriteMonth .= "$BD"; 
                                break; 
                        case 'Thu': 
                                if($TBD==1) 
                                         
$WriteMonth .= "<td> </td><td> </td><td> </td><td> </td>"; 
                                $WriteMonth .= "$BD"; 
                                break; 
                        case 'Fri': 
                                if($TBD==1) 
                                         
$WriteMonth .= "<td> </td><td> </td><td> </td><td> </td><td> </td>"; 
                                $WriteMonth .= "$BD"; 
                                break; 
                        case 'Sat': 
                                if($TBD==1) 
                                         
$WriteMonth .= "<td> </td><td> </td><td> </td><td> </td><td> </td><td>  
;</td>"; 
                                $WriteMonth .= "$BD"; 
                                $WriteMonth .="</tr><tr>"; 
                                break; 
                        } 
        } 
                                $WriteMonth .="</table>"; 
        return $WriteMonth; 
} 
echo "</TD></TR>"; 
echo "</TABLE>"; 
echo "<BR>"; 
echo "</body>"; 
echo "</html>";
 

Report Bug

Please Login to Report Bug

Reported Bugs

Comments

Please Login to Comment

Comments