Hello everybody,
am New in PHP. I would appreciate some help in the below code . What i need is a yearly calender that displays only the months without days .So i can load the data on a monthly basis.
<?php
defined( '_VALID_MOS' ) or die( 'Restricted access' );
require_once( $mainframe->getPath( 'front_html' ) );
// page title
$mainframe->setPageTitle( 'Callout' );
echo "
<center>";
//Check for a Month Change submission
if (isset($_POST['submit']))
{
$submit = $_POST['submit'];
$month_now = $_POST["month_now"];
$year_now = $_POST["year_now"];
// Subtract one from the month for previous, add one for next
//<body bgcolor='pink'>
if ($submit == "Prev")
{
if($month_now >6 && $year_now >= 2007)
$year_now--;
else if($month_now <=6 && $year_now > 2007)
$year_now--;
}
else
{
if($month_now < date("m") && $year_now <= date("Y"))
$year_now++;
else if($month_now > date("m") && $year_now < date("Y"))
$year_now++;
}
$date = getdate(mktime(0,0,0,$month_now,1,$year_now));
}
else
{
$date = getdate();
}
$month_num = $date["mon"];
$month_name = $date["month"];
$year = $date["year"];
$date_today = getdate(mktime
(0,0,0,$month_num,1,$year));
$first_week_day = $date_today["wday"];
$cont = true;
$today = 27;
while (($today <= 32) && ($cont))
{
$date_today = getdate(mktime(0,0,0,$month_num,$today,$year));
if ($date_today["mon"] != $month_num)
{
$lastday = $today - 1;
$cont = false;
}
$today++;
}
// allow for form submission to the script for forward
//and backwards
echo"<table width=\"300\" border=\"1\" cellspacing=4 cellpadding=2 style='text-align:center; font-
size:30.0pt;font-family:veranda; style=text-weight:bold; color:#666666'>
<tr align=center style='font-weight:bold'><td colspan=\"7\">$year</td>
</tr>";
// begin placement of days according to their
//beginning weekday
$day = 1;
$month = 1;
$wday = $first_week_day;
$firstweek = true;
// make each day linkable to the following filec2.php
//page
if ( intval($month_num) < 10) { $new_month_num = "0$month_num"; }
elseif (intval($month_num) >= 10)
{
$new_month_num = $month_num;
}
if ( intval($day) < 10) { $new_day = "0$day";
}
elseif (intval($day) >= 10) { $new_day = $day;
}
//$link_date = "$new_day-$new_month_num-$year";
//$today_year = date("Y");
$today_year = date("Y");
$today_month = date("F");
$today_day = date("j");
$today_month_num = date("m");
if($day == $today_day && $month_name == $today_month && $year == $today_year)
$colour = 'yellow';
else
$colour = '#FFFCC0';
$link_date = "$year$new_month_num";
if($day <= $today_day && $new_month_num <= $today_month_num && $year == $today_year)
{
if (is_file('.\res\Callout\callout'.$link_date.'.xls' ))
echo "<a href=res\Callout\callout$link_date.xls target=\"_blank\"> $month_name
</a></td>";
else
echo "$month_name ";
}
else if($day > $today_day && $new_month_num < $today_month_num && $year <= $today_year)
{
if (is_file('.\res\Callout\callout'.$link_date.'.xls' ))
echo "<a href=res\Callout\callout$link_date.xls
target=\"_blank\"> $month_name </a></td>";
else
echo "$month_name ";
}
else if($new_month_num >= $today_month_num && $year < $today_year)
{
if (is_file('.\res\Callout\callout'.$link_date.'.xls' ))
echo "<a href=res\Callout\callout$link_date.xls target=\"_blank\"> $month_name
</a>";
else
echo "$month_name ";
}
if ($month_name==12)
{
echo "</tr>\n";
}
//$wday++;
//$wday = $wday % 7;
$month_name++;
//}
echo"
</table>
<br>
";
?>