作业2-1要求
展示页面:http://www.dshui.wang/html/work1.php
可以在地址后面加参数哟!
如:http://www.dshui.wang/html/work1.php?colnum=7 试试看吧!最大31

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<?php
#Designed By Anthony_Box
#Date: 2015-05-07
#201321092028 OF SCUEC
$colnum = $_GET['colnum']?$_GET['colnum']:5;
if($colnum>31){
$colnum = 5;
}
echo "<table border='1px' bordercolor='yellow'>\n\t<tr>\n";
for($i=0;$i<$colnum*$colnum;$i++){
if(!($i%$colnum)){
echo "\n\t</tr>\n\t<tr>\n";
}
if($i%2){
echo "\t\t<td style='text-align: center;'>";
}else{
echo "\t\t<td style='background-color: red;text-align: center;'>";
}
echo $i+1;
echo "</td>";
}
echo "\n\t</tr></table>";
?>