PHP输出表格的方法

<?php
 function table($n) //几行几列表
 {
     echo'<table  border="1" width="500" height="200" align="center"  bordercolor=green             cellpadding="0 "cellspacing="0">';  
     echo '<caption><h1>表名</h1></caption>';
     for($i=0;$i<$n;$i++)
     {  
            if($i%2==0)
               $bg="#ffffff"; 
        else
              $bg="#cccccc";
        echo'<tr bgcolor="'.$bg.'">';
            for($j=0;$j<$n;$j++)
             { 
            echo '<td></td>'    ;     
             }
        echo'</tr>';
          }
      echo'</table>';
}
   table(10);
?>

 

posted @ 2015-08-20 23:07  骏码信息  阅读(1832)  评论(0编辑  收藏  举报