输出一个表格
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ />
23ptable<body>
<?php
echo ‘
‘;
echo ‘使用一个while循环输出表格‘;
$i=0;
while($i<100){
)本文来源gaodai.ma#com搞#代!码网_
搞代gaodaima码
if($i%10==0){
echo “
“;} #此处,$i%10=0,正好条件语句成立,输出
echo ““.$i.” | “;
$i++; #此处,$i自加,变成了1
if($i%10==0){
echo “
“;} /*此处,$i=1,表格不会换行;假设在执行$i++之前,$i=9,执行后$i=10,正好换行;若把$i++放在该if后面,
|
正好成对换行,后面的循环会自成 一行,上句$i++与++$i效果一样*/
}
echo “
“;
?>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
还可以实现隔行换色
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ />
23ptable<body>
<?php
echo ‘
‘;
echo ‘使用一个while循环输出表格‘;
$i=0;
while($i<100){
if($i%10==0){
if($i%20==0){$bg=”#fff999″;}else{$bg=”#333fff”;} //效果如下图
echo “
“;}
echo ““.$i.” | “;
$i++;
if($i%10==0){
echo “
“;}
}
echo “
“;
?>