PHP学习笔记之用php绘制表格示例
<!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]\"") ?>> </td>
<td width="40" height="40" <?php $r = rand(1, 9999); echo("bgcolor=\"$color[$r]\"") ?>> </td>
</tr>
<tr>
<td width="40" height="40" bgcolor="#FFFF00"> </td>
<td width="40" height="40" bgcolor="#FF00FF"> </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>
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。