PHP Instance ———— Table Calendar

Source: Internet
Author: User

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>";? >

:





Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.