Php learning implementation code of the Loop Structure

Source: Internet
Author: User

Copy codeThe Code is as follows: <? Php
/* Loop Structure
* 1. while Loop
* While (expression)
*{
* Loop body; // execute repeatedly until the expression is false.
*}
* 2. do-while loop
* 3. for Loop
*
* There are two types of loops based on different cyclic conditions.
*
* One Type: Counting loop ()
* Another type: Conditional loop (usually while do-while)
*
*
*
*/
// While usage
/* $ Num = 0;
While ($ num <100)
{
Echo "output result {$ num }";
$ Num ++;
}*/
// While output table
Echo '<table border = "1" width = "800" align = "center"> ';
Echo '<caption> $ I = 0;
While ($ I <1000)
{
// Change a row every 10 times
If ($ I % 10 = 0)
{
If ($ I % 20 = 0)
{
$ Bg = "# ffffff ";
}
Else
{
$ Bg = "# cccccc ";
}
Echo '<tr onmouseover = "orow (this)" onmouseout = "nrow (this)" bgcolor ='. $ bg. '>'; // the color of the output line.
}
Echo '<td>'. $ I. '</td> ';
$ I ++;
If ($ I % 10 = 0)
{
Echo '</tr> ';
}
}
Echo '</table> ';
?>
<Script type = "text/javascript">
Var old = null;
// The Yellow background is displayed when you place the cursor.
Function orow (obj)
{
Old = obj. bgColor;
Obj. bgColor = 'yellow ';
}
// Returns the original color when the mouse leaves.
Function nrow (obj)
{
Obj. bgColor = old;
}
</Script>

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.