zoukankan      html  css  js  c++  java
  • 使用PHP输出 多行多列表格

    前一段时间遇到这样一个需求,需要输出一个2行6列的表格,开始的时候我的想法是使用for循环来控制输出,可是一直没有实现,在输出表格的时候,打印出单元格的数字序列。

    今天使用学习php的时候,实现了,不过使用的是while循环。

    界面:

    吧代码写下,做个记录:

    <?php
    /**
    * @porject name:while循环
    * @description :
    * @version :1.0 
    * @author : Jack
    * @create date:2012-11-9 ����02:32:41
    * @copyright(c) 2012
    ------------Modify Record------------
    */
    ?>
    
    <!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>while</title>
        </head>
        
        <body>
            <form action="#" method="post">
                <table align="center" border="1">
                    <?php 
                        $i=0;
                        while ($i<10)
                        {
                            //改变下各行的颜色
                            if($i%2===0){
                                $bgcolor="#ffffff";
                            }else {
                                $bgcolor="#dddddd";
                            }
                            echo "<tr bgcolor=".$bgcolor.">";
                            $in=0;//计算累加变量                        
                            while($in<10)
                            {
                                echo "<td>".($i*10+$in)."</td>";
                                $in++;
                            }
                            echo "</tr>";
                            $i++;
                        }
                        
                    ?>
                </table>
            </form>
        </body>
    </html>
  • 相关阅读:
    对Spring <context:annotation-config/>的理解
    Javascript this指针
    go 打造世界最快的go模板引擎gorazor 2.0
    swagger 部署(Mac )
    Ab测试
    Nginx tcp限制并发、IP、记日志
    Nginx proxy_protocol协议与realip模块
    数据结构之回溯
    数据结构之分治
    数据结构之二分查找
  • 原文地址:https://www.cnblogs.com/acoll/p/2762658.html
Copyright © 2011-2022 走看看