<html>
<head>
<title>使用while循环嵌套输出表格</title>
</head>
<body>
<?php
echo"<table align='center' border=1 width=600>";
echo"<caption>";
echo"<h1>使用while循环嵌套输出表格</h1>";
echo"</caption>";
$out=0;
while($out<10){
if($out%2==0){
$bgcolor="#ffffff";
}else{
$bgcolor="#dddddd";
}
echo"<tr align='center' bgcolor=".$bgcolor.">";
$in=0;
while($in<10){
echo"<td>".($out*10+$in)."</td>";
$in++;
}
echo"</tr>";
$out++;
}
echo"</table>";
?>
<?php
echo"<table align='center' border=1 width=600>";
echo"<caption>";
echo"<h1>使用for循环嵌套输出表格</h1>";
echo"</caption>";
for($ou=0;$ou<10;$ou++){
if($ou%10==0)
$bgc="#ffffff";
else
$bgc="#dddddd";
echo"<tr align='center' bgcolor=".$bgc.">";
for($it=0;$it<10;$it++){
echo"<td>".(10*$ou+$it)."<?td>";
}
echo"</tr>";
}
echo"</table>";
?>
</body>
</html>
用while和for循环嵌套输出表格
最新推荐文章于 2022-04-18 17:12:44 发布