Calender "SORTED"

I’m trying to create a 12 month calenar but have run into a problem.

I have the calender showing ok but instead of the dates being in weekly format they are monthly. Here the code you’ll see what I mean

[php]

<?php $cur_year = date('Y'); for ($i=1; $i <= 12;$i++) { ?>
<table cellpadding="1" cellspacing="1" bgcolor="#666666">
<tr><td colspan="7" align="center" valign="top" bgcolor="#99CCCC" style="color:#FF3300; font-weight:bold; font-size:16px"><?php echo date('F Y', mktime(0,0,0,$i,1,$cur_year))  ?></td>
</tr>
<tr>
<?php for($day_title = 5; $day_title <= 11; $day_title++) { ?><td valign="top" bgcolor="#99CCCC" style="color:#000066; font-weight:bold; font-size:10px"><?php echo date('D', mktime(0,0,0,0,$day_title,0))  ?></td><?php } ?></tr>




<?php
$start_day = date('d', mktime(0,0,0,$i,1,$cur_year));
$end_day = date('t', mktime(0,0,0,$i,1,$cur_year));

?>

<tr><?php foreach(range($start_day, $end_day) as $week_days) { ?>
<td align="center" style="color:#FF0000"><?php echo  $week_days; ?></td><?php
} 
?></tr>
<?php } ?>

[/php]

Does anyone have any suggestions.
Have tried $trs = $end_day /7; for($rows=0; $rows < $trs; $rows++) { and so on.

It gives extra rows but puts all the months dates in 1 cell

I’m now getting somewhere, all the dates are filled and the rows are correct. Troble is the dates are all the same.

[php]

<?php $month = date('F'); $year = date('Y'); $first_day = date('w',mktime(0,0,0,$month,0,$year)); $start_day = date('d', mktime(0,0,0,$month,0,$year)); $end_day = date('t', mktime(0,0,0,$month,0,$year)); $daysinweek = date('w', mktime(0,0,0,$month,0,$year)); for ($month=0; $month <= 17;$month++) { ?>
<table cellpadding="1" cellspacing="1" bgcolor="#666666">
<tr><td colspan="7" align="center" valign="top" bgcolor="#99CCCC" style="color:#FF3300; font-weight:bold; font-size:16px"><?php echo date('F Y', mktime(0,0,0,$month,0,$year))  ?></td>
</tr>
<tr>
    <th width="20" align="center" bgcolor="#993300">Mo</th>
    <th width="20" align="center" bgcolor="#993300">Tu</th>
	<th width="20" align="center" bgcolor="#993300">We</th>
	<th width="20" align="center" bgcolor="#993300">Th</th>
	<th width="20" align="center" bgcolor="#993300">Fr</th>
	<th width="20" align="center" bgcolor="#993300">Sa</th>
	<th width="20" align="center" bgcolor="#993300">Su</th>
</tr>
<?php
for ($i=0;$i<$daysinweek;$i++)

{
?>

 
<?php
}
for ($list_day=1;$list_day<=$end_day;$list_day++)
{

?>

<?php echo $list_day ?>
<?php
if ($daysinweek == 6)
{
?>
<?php
$daysinweek = -1;
}
$daysinweek++;
}
?>
<?php } ?>

[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service