三种php表格隔行换色

第一种for{}eles{}:

  

     <?php
          echo "<table width=‘80%‘ border = 1 cellpadding=5 cellspacing=0>";
          for ($i = 1; $i <= 5; $i++){
          if($i % 2 == 0){
          echo ‘<tr align="center" bgcolor="red">‘;
          }else{
          echo ‘<tr align="center">‘;
          }

          for ($j = 1; $j<= 8; $j++){

          echo ‘<td>‘.$i * $j.‘</td>‘;

          }
          echo ‘</tr>‘;
          }
            echo ‘</table>‘;

          ?>

第二种方法while

          

            <?php
              echo "<table width=‘80%‘ border = 1 cellpadding=5 cellspacing=0>";
              $l = 1;
              while ($l <= 5) {
              if ($l % 2 == 0) {
              echo ‘<tr align="center" bgcolor="red">‘;
                }else{
              ‘<tr align="center">‘;
              }

              $m = 1;
              while ($m <= 8) {
                echo ‘<td>‘.$l * $m.‘</td>‘;
              $m++;
              }
              echo ‘</tr>‘;
              $l++;
              }

              ?>

第三种方法do{}while{}

              <?php      

              echo "<table width=‘80%‘ border = 1 cellpadding=5 cellspacing=0>";
              $k = 1;
              do{
              if($k % 2 == 0){
              echo ‘<tr align="center" bgcolor="red">‘;
              }else{
              echo ‘<tr align="center">‘;
              }
              $n = 1;
              while ($n <=8) {
              echo ‘<td>‘.$k * $n .‘</td>‘;
              $n++;
              }
              echo ‘</tr>‘;
              $k++;
              }while($k <= 5);

            ?>

  

三种php表格隔行换色,布布扣,bubuko.com

时间: 2025-02-01 14:07:05

三种php表格隔行换色的相关文章

jQuery实现的table表格隔行换色代码实例

jQuery实现的table表格隔行换色代码实例:下面是一段代码实例,能够实现隔行变色的效果,这是网站人性化措施之一,在实际应用中的使用非常广泛.代码如下: <!DOCTYPE html> <html> <head> <meta charset=" utf-8"> <meta name="author" content="http://www.softwhy.com/" /> <t

jQuery实现表格隔行换色且感应鼠标高亮行变色

jQuery插件实现表格隔行换色且感应鼠标高亮行变色 http://www.jb51.net/article/41568.htm jquery 操作DOM的基本用法分享http://www.jb51.net/article/30047.htm jQuery技术之事件处理 http://blog.csdn.net/woshisap/article/details/7434010 jQuery实现表格隔行换色且感应鼠标高亮行变色,布布扣,bubuko.com

表格隔行换色及删除后仍隔行换色效果(好别扭的标题。。。)

表格隔行换色,有多种写法,可以通过jquery来写,也可以用css3实现. 1.jquery方法 odd,奇数:even,偶数 方法很简单 $("tr:odd").css({background:"#c66",color:"#fff"}); $('tr:even').css({background:"#fff",color:"#333"}); 但是如果删除后,两个一样背景的tr会挨上,怎么解决呢?可以将换行

jQuery应用实例2:表格隔行换色

这里是用JS实现的:http://www.cnblogs.com/xuyiqing/p/8376312.html 接下来利用上一篇提到的选择器利用jQuery实现: 发现原来多行代码这里只需要两行: <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>表格隔行换色</title> <script type="text/javascr

JQuery案例一:实现表格隔行换色

<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>使用JQ完成表格隔行换色</title> <script src="js/jquery.min.js"></script> <script> $(function() { $("tbody tr:odd").css(&qu

表格隔行换色

实现列表中隔行显示背景颜色 Html代码 <div class="searchListDetail"> <ul class="bold"> <li>姓名</li><li>公司</li><li>职位</li><li>标签</li><li>性别</li><li>工作年限</li> </ul>

js表格隔行换色和hover效果

<!--js效果--> <script src="js/jquery.min.js" language="javascript"></script> <script> $(document).ready(function(){///////datagrid选中行变色与鼠标经过行变色///////////////var dtSelector = ".list";var tbList = $(dtSel

表格 隔行换色

1.原生JS实现 1 <script type="text/javascript"> 2 var oTable = document.getElementById("table"); 3 var oTr = oTable.getElementsByTagName("tr"); 4 for (var i=0; i<oTr.length;i++) 5 { 6 if (i%2) 7 oTr[i].style.background =

JQ表格隔行换色

<style type="text/css"> html, body { margin: 0; padding: 0; font-size: 15px; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; } ul { list-style: none; border: 1px solid #5bc0de; width: 600px; margin: 0 auto; padding: