php输出表格 改进版

来源:互联网 发布:cf客户端数据异常23 0 编辑:程序博客网 时间:2024/05/22 12:49
<?php
echo "<table border=0.5 width=80% align=center>";
print"<caption><h2>xxx</h2></caption>";
$i=1;
$k=1;
   while($i<=10){ 
   if($i%2==0){$bgc="#66ff66";}else{$bgc="#00ffff";}
   echo"<tr bgcolor='$bgc' onmouseover='show(this);' onmouseout='noshow(this);'>";
   $j=1;
   while($j<=10){
   echo"<td>".$k++."</td>";
   $j++;
   }
   echo"</tr>";
   $i++;
}
print("</table>");
echo"<hr size=2>";
print "<table border=0.5 width=80% align=center>";
for($i=1;$i<11;){
   if($i%2==0){$bgc="#666666";}else{$bgc="#ff11ff";}
   echo"<tr bgcolor='$bgc' onmouseover='show(this);' onmouseout='noshow(this);'>";
   $j=1;
   for(;$j<=10;){
   $a=rand();
   echo"<td>".$a."</td>";
   $j++;
   }
   echo"</tr>";
   $i++;
}
print("</table>");
?>
<script language="javascript">
  function show(obj){
  obj.style.backgroundColor="red";
  }
  function noshow(obj){
  obj.style.backgroundColor="";
  }
</script>
原创粉丝点击