php learning loop structure implementation code

  • 2020-05-07 19:20:26
  • OfStack

 
<?php 
/*  Loop structure  
* 1. while cycle  
* while( expression ) 
* { 
*  The loop body ;// Repeat until the expression is false  
* } 
* 2. do-while cycle  
* 3. for cycle  
* 
*  Depending on the cycling conditions, there are two types of cycling  
* 
* 1 Species: counting cycles  (1 Like to use for) 
*  On the other 1 Species: conditional cycle  (1 Like to use  while do-while) 
* 
* 
* 
*/ 
//while The use of  
/*$num=0; 
while($num<100) 
{ 
echo " The output {$num}"; 
$num++; 
}*/ 
//while The output form  
echo '<table border="1" width="800" align="center">'; 
echo '<caption><h1> use while The output form </h1></caption>'; 
$i=0; 
while($i<1000) 
{ 
// every 10 Time to change 1 line  
if($i%10==0) 
{ 
if($i%20==0) 
{ 
$bg="#ffffff"; 
} 
else 
{ 
$bg="#cccccc"; 
} 
echo '<tr onmouseover="orow(this)" onmouseout="nrow(this)" bgcolor='.$bg.' >';// Output alternate color  
} 
echo '<td>'.$i.'</td>'; 
$i++; 
if($i%10==0) 
{ 
echo '</tr>'; 
} 
} 
echo '</table>'; 
?> 
<script type="text/javascript"> 
var old=null; 
// Displays a yellow background when the mouse is over  
function orow(obj) 
{ 
old=obj.bgColor; 
obj.bgColor='yellow'; 
} 
// Returns the original color when the mouse moves away  
function nrow(obj) 
{ 
obj.bgColor=old; 
} 
</script> 

Related articles: