Hi, This is my first PHP code submission at www.weberdev.com. Except for the distorted indentation
(if at all) there should be no problem with the code.
The code is for generating Calender in PHP. Hope it will be useful. Database features could be
added to the calender to make automated functions execute.
Thank you,
Srikanth Turaga.
PSS: Please email me at skturaga@yahoo.com incase if you find some problem in executing this code.
Code follows :
<?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>" ;
?>
Calendar using Date function Categories : HTML and PHP , PHP , Date Time , Calendar CALENDAR - easy calendar-navigation with PHP Categories : PHP , Date Time , HTML and PHP , Calendar Dynamic Calendar in PHP, Javascript and HTML. Categories : PHP , Java Script , HTML and PHP , Calendar php html calendar dynamic Categories : HTML and PHP , PHP , Calendar Customizable Calendar Class Categories : HTML and PHP , Date Time , PHP , PHP Classes , Calendar PHP3: Formmail. Just a cgi formmail, but than in PHP. It is easy to use! Categories : HTML and PHP , Email , PHP , Perl , HTML and PHP Simple PHP control CSS Calendar Categories : PHP , HTML and PHP , Calendar , Date Time , CSS This script contains 2 functions: 1 to create html select object based on your own customer date format entry- "M d Y h:i.... etc". The second function processes the select object on submit back to unix time. Categories : PHP , Calendar , Date Time , HTML and PHP Pseudo Non Parsed Header. Output to the the browser as the script runs. Categories : PHP , HTTP , HTML and PHP Website colour changer Categories : PHP , HTML and PHP , Date Time Kewl Date Example Categories : PHP , HTML and PHP , Date Time , CSS , Beginner Guides Multiple Select box, Select multiple Items from Menu.List box Categories : PHP , HTML and PHP , Beginner Guides mySQL/PHP/search with multientry
form and table output with colored rows Categories : PHP , Beginner Guides , MySQL , HTML and PHP , Databases Print out array key => value in colored HTML Categories : PHP , Arrays , HTML and PHP XTemplate, a template class for PHP Categories : PHP Classes , HTML and PHP , PHP