"for" loop inside another "for" loop
<p><br>
I have quick question, and I'm sure some of you guys will be able to point out what I'm doing wrong.<br>
Basically, I want to create a table with (calendar), with the months and days of an entire year, and Im using php to do it, my code is doing something weird.
What happens is that January is empty and the days for January are being put in february.<br>
My code so far is as follows:</p>

<pre><code>$months = 12;
$monthsOfTheyear = array("Januany","February","March","April","May","June","July","August","September","October","November","December");
$currentMonth = date("n");
$currentYear = date("Y");
$daysOfTheMonth = cal_days_in_month(CAL_GREGORIAN, $currentMonth, $currentYear);
for($i = 0; $i &lt; $months; $i++){
echo    "   &lt;tbody class='month'&gt;";
echo    "       &lt;tr&gt;
                    &lt;td colspan='".$daysOfTheMonth."'&gt;
                        ".$monthsOfTheyear[$i]."
                    &lt;/td&gt;
                &lt;/tr&gt;
                &lt;tr&gt;
        ";
$daysOfEachMonth = cal_days_in_month(CAL_GREGORIAN, $i, $currentYear);
    for($d = 1; $d &lt;= $daysOfEachMonth; $d++){

        echo    "   &lt;td&gt;
                        ".$d."
                    &lt;/td&gt;
                ";
    }
    echo    "       &lt;/tr&gt;
            &lt;/tbody";
}
</code></pre>

<p>I'm obviously doing something wrong, but I've been staring at the monitor for about an hour trying to figure it out.<br>
I'd appreciate any advice.<br>
Thanks</p>
