码迷,mamicode.com
首页 > Web开发 > 详细

PHP学习笔记之用php绘制表格示例

时间:2015-01-28 18:01:43      阅读:184      评论:0      收藏:0      [点我收藏+]

标签:





<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>用php绘制表格示例</title>


<?php
  define(MAX_NUM, 20);
  $bc = "000000";
  $color = array();
  for ($i=0; $i<10000; $i++)
  {
$color[$i] = "#" . $bc;
$bc += 0x00000f;
//echo($color[$i] . "\t");
  }
  echo "<hr/>";
  
 
?>
</head>


<body>


<table border="2" cellspacing="0" cellpadding="0">
  <tr>
    <td width="40" height="40" <?php $r = rand(1, 9999); echo("bgcolor=\"$color[$r]\"") ?>>&nbsp;</td>
    <td width="40" height="40" <?php $r = rand(1, 9999); echo("bgcolor=\"$color[$r]\"") ?>>&nbsp;</td>
  </tr>
  <tr>
    <td width="40" height="40" bgcolor="#FFFF00">&nbsp;</td> 
    <td width="40" height="40" bgcolor="#FF00FF">&nbsp;</td>
  </tr>
</table> 


<table cellspacing="0" cellpadding="0">
  <?php
  for ($i=1; $i<=MAX_NUM; $i++)
  {
echo("<tr>");
for ($j=1; $j<=MAX_NUM; $j++)
{
$s = $i * $j;
$r = rand(1, 9999);
echo("<td  align=center width=\"40\" height=\"40\" "); 
echo(" bgcolor=\"$color[$r]\">   </td>");

}
echo("</tr>");
  }
  ?>
</table>


</body>
</html>

PHP学习笔记之用php绘制表格示例

标签:

原文地址:http://blog.csdn.net/qiaoruozhuo/article/details/43232413

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!