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>