|
|
|
|
|
|
| |
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>";
?> | | |
|
| 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 | | | a function that builds an HTML select list from any mysql table. Categories : PHP, MySQL, HTML and PHP | | | Tag content retrieval from websites with preg_match Categories : PHP, Regexps, Arrays, HTML and PHP | | | Message of the Day - Random Message (Needs MySQL!) Categories : Databases, HTML and PHP, PHP, MySQL | | | Check parameters validity. Paranoia was designed to check the validity of the parameters that a php page will receive after a form submission. It can be used to check the variables sent by POST or GET Categories : Algorithms, HTML and PHP, PHP, Variables | | | Alternating background color for HTML table rows Categories : PHP, Databases, MySQL, HTML and PHP | | | Constantly refresh your PHP/HTML page data. Categories : PHP, HTML and PHP, Sybase | | | background music script for random notes in a frame Categories : PHP, Content Management, HTML and PHP | | | A very simple way to build and do a hierarchical html categories browser without javascript , just using html php and mySql
Categories : HTML and PHP, Databases, Algorithms, PHP, MySQL | | | Random Image Display Categories : PHP, Filesystem, Graphics, HTML and PHP | | | PhpView 0.1 - simple php viewer, using temporary files and frames.
Categories : PHP, PHP Options and Info, Debugging, HTML and PHP | | | Automatically printing the contents of an sql table in MySQL. Categories : MySQL, PHP, HTML and PHP, Databases | | | PHP template processing Categories : PHP, Templates, HTML and PHP | | | XDT Topsite (Gold v1.0) Categories : Databases, CSS, PHP, HTML and PHP, Sessions | | | function textwrap will wrap text to any desired width using <BR>\n as the default line break.
Default wrap width is 80 columns.
Categories : Strings, HTML and PHP, PHP | |
|
|
|