Use the <table> form to make a simple calendar page.
Requirements:
1. Follow the Windows Calendar, 5 rows 7 columns, and the date is centered.
2. Interlaced color change (background color).
3. Cell spacing and margins are zero.
Precautions:
1. Nested loops are required to control rows and columns.
2. The counter calculates the number of rows to facilitate color change.
3. In a line of statements, double quotation marks cannot be mixed with double quotes, and they must be separated by single quotation marks.
4. The position where the $i increment. This is the highlight of the whole algorithm.
Code:
<?php$days=31; $line =0;//record lines//table echo "<table style= ' width:500px;border:1px solid black ' cellspacing= ' 0 ' cellpadding= ' 0 ' > '; for ($i =1; $i < $days;) {//Line $line++;if ($line%2==1) {echo "<tr style= ' background: #e0ffff ' > ";} Else{echo "<tr style= ' background: #ff00ff ' >";} column for ($j =1; $j <8; $j + +) {if ($i > $days) {echo "<td style= ' border:1px solid black ' > </td>";} Else{echo "<td style= ' border:1px solid black; ' align=center>{$i}</td> ';} $i + +;} echo "</tr>";} echo "</table>";? >
: