This is my code so far..
[code=php]
<section id=”content” class=”planner”>
<h2>
<?php
$date_db = strtotime(“07/01/2011”);
echo date(“F Y”, $date_db)
?>
</h2>
<table class=”month”>
<tr class=”days”>
<td>Mon</td>
<td>Tues</td>
<td>Wed</td>
<td>Thurs</td>
<td>Fri</td>
<td>Sat</td>
<td>Sun</td>
</tr>
<?php
$today = date(“d”, $date_db); // Current day
$month = date(“m”, $date_db); // Current month
$year = date(“Y”, $date_db); // Current year
//die($today);
/*
$today = date(“d”); // Current day
$month = date(“m”); // Current month
$year = date(“Y”); // Current year
*/
$days = cal_days_in_month(CAL_GREGORIAN,$month,$year); // Days in current month
$lastmonth = date(“t”, mktime(0,0,0,$month-1,1,$year)); // Days in previous month
$start = date(“N”, mktime(0,0,0,$month,1,$year)); // Starting day of current month
$finish = date(“N”, mktime(0,0,0,$month,$days,$year)); // Finishing day of current month
$laststart = $start – 1; // Days of previous month in calander
$counter = 1;
$nextMonthCounter = 1;
//if the start day is greater than a Friday; if it is, we have 6 rows, otherwise we have 5
if($start > 5){ $rows = 6; }else {$rows = 5; }
//we then have a nested loop – one for the weeks, and one for the days in the weeks
for($i = 1; $i <= $rows; $i++){
echo ‘<tr class=”week”>’;
for($x = 1; $x <= 7; $x++){
if(($counter – $start) < 0){
$date = (($lastmonth – $laststart) + $counter);
$class = ‘class=”blur”‘;
echo ‘<td ‘.$class.’><a class=”date”></a></td>’;
}else if(($counter – $start) >= $days){
$date = ($nextMonthCounter);
$nextMonthCounter++;
$class = ‘class=”blur”‘;
echo ‘<td ‘.$class.’><a class=”date”></a></td>’;
}else {
$date = ($counter – $start + 1);
if($today == $counter – $start + 1){
$class = ‘class=”today”‘;
}
echo ‘<td ‘.$class.’><a class=”date”>’. $date . ‘</a></td>’;
}
$counter++;
$class = ”;
}
echo ‘</tr>’;
}
?>
</table>
</section>
I’ve got it outputting one month so far but not organizing the items into it and not showing 5 months instead of one. Most of that code is from a tutorial. What I want to do is output 5 months (current and 4 in the future) and loop through items in my database and have PHP sort the items into the calendar. Any advice on where I go from here?