Thursday, November 17, 2011

I have the homework section of my site up, as I  cannot turn in assignments without uploading it to my personal webspace, and since I was making a site, and would like practice, I though "eh, why not?"

I do not intend to keep each item I post on their, I will make a page for end of term papers and such, but not assignments worth 5 points.
http://webspace.globeuniversity.edu/arthur.taylor/

php code as follows

<p>Using loop constructs, produce a PHP script which will output a calendar for a normal February (28 days).<br />  You will need to define variables to contain the start day of the month (Sunday, Monday, etc.) and the number of days in the month.<br />
For each day of the month that is an even number, print the value in bold text. Begin the Month on Saturday </p>

<?php
// File: exercise9-6.php

$intStartDayOfMonth = 6;    // Tuesday Start of Month
$intDaysInMonth = 28;       // Days in Month
?>
<table border = '1'>
<tr><td>S</td><td>M</td><td>T</td><td>W</td><td>T</td><td>F</td><td>S</td></tr>
<tr>
<?php
for($intCurrentWeekDay=0;$intCurrentWeekDay<$intStartDayOfMonth;$intCurrentWeekDay++)
    echo "<td></td>";
$intDay = 1;
while($intDay <= $intDaysInMonth) {
if ($intDay % 2)
echo "<td>$intDay</td>";
else {
echo "<td><b>$intDay<b></td>";
}

 
    $intDay++;
    $intCurrentWeekDay++;

    if ($intCurrentWeekDay == 7) {
        $intCurrentWeekDay = 0;
        echo "</tr><tr>";
    }
}
for(;$intCurrentWeekDay<7;$intCurrentWeekDay++)
    echo "<td></td>";
?>
</tr></table>

No comments:

Post a Comment