php利用while单循环实现100行10列表格输出且每行颜色不一样

浏览:2545 发布日期:2016/09/28 分类:技术分享
<?php  

echo "<table border=1 align=center width=800>";  

echo "<caption><h1>学生成绩表</h1></caption>";  

$i=0;  

$j=0;  

while($i<1000){  

if($i%10==0){  

if($j++%2==0){  

   $bgc="#cccccc";  

}else{  

   $bgc="#aaffaa";  

}  

          echo "<tr onmouseover='show(this)' onmouseout='noshow(this)' bgcolor='".$bgc."'>";  

        }  

echo "<td>".$i."</td>";  

  

  

if(++$i%10==0){  

          echo "</tr>";  

}  

}  

echo "</table>";  

?>   

<script>  

function show(obj){  

      yc=obj.style.backgroundColor;  

               obj.style.backgroundColor="red";  

       }    

       function noshow(obj){  

               obj.style.backgroundColor=yc;  

       }  

</script> 
最佳答案
评论() 相关
后面还有条评论,点击查看>>