All pastes #73496 Raw Edit

Miscellany

public text v1 · immutable
#73496 ·published 2006-06-27 22:21 UTC
rendered paste body
<?php $d = 1;
    $wday = $firstwday;
    $firstweek = true;

    /*== loop through all the days of the month ==*/
    while ( $d <= $lastday)
    {

        /*== set up blank days for first week ==*/
        if ($firstweek) {

			if ($firstwday !==0){
		    echo "<tr><td colspan='$firstwday' bgcolor='#C0C0C0'><font size=2>&nbsp;</font></td>";
		    $firstweek = false;
		    }
			}


        /*== Sunday start week with <tr> ==*/
        if ($wday==0) { echo "<tr>"; }

        /*== display the day ==*/
        echo "<th align='center'>";
        echo "<a href=\"?d=$d&m=$m&y=$y\"><font size='2'color='#000000'>$d</font></a>";
        echo "</th>\n";

        /*== Saturday end week with </tr> ==*/
        if ($wday==6) { echo "</tr>\n"; }

        $wday++;
        $wday = $wday % 7;
        $d++;


    }

    /*== set up blank days for end of the week ==*/
 	if ($wday = $wday % 7)
    {$remainingDays = 7 - $wday;
	echo "<td colspan='$remainingDays' bgcolor='#C0C0C0'>&nbsp;</td>";
	}

echo ("</tr></table>");

/*== end drawCalendar function ==*/
}




/*== get the last day of the month ==*/
function mk_getLastDayofMonth($mon,$year)
{
    for ($tday=28; $tday <= 31; $tday++)
    {
        $tdate = getdate(mktime(0,0,0,$mon,$tday,$year));
        if ($tdate["mon"] != $mon)
        { break; }

    }
    $tday--;

    return $tday;
}

?>