duangekui7451 2018-06-20 14:12 采纳率: 0%
浏览 62
已采纳

PHP For Loop中的每个第7和第8个表单元格样式

I know you can set every nth row or cell of a table to have certain attributes in a for Loop

   if($ib % 7){
   echo '<td>'.$ib.'</td>';
   }
  else{
  echo '<td bgcolor="005082"></td>';
  }

But can you do the same for the next row aswell. In other words can I set every 7th and 8th table cell next to each other to have the same colour? I'm building a calendar and want to highlight the weekend.

  • 写回答

2条回答 默认 最新

  • douni9620 2018-06-20 14:15
    关注

    You mean like

    if($ib % 7 == 0 || $ib % 7 == 1){
        echo '<td bgcolor="005082"></td>';
    }
    else {
        echo '<td>'.$ib.'</td>';
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
  • dongzhuifeng1843 2018-06-20 14:32
    关注

    In case you would achieve it using CSS nth-child

    table tr td:nth-child(7n+7), table tr td:nth-child(7n+8) {
        background: #005082;
    }
    

    I selected 6th & 7th elements as a week lasts 7 days...

    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 我用C语言easyx图形库绘制了一个3d游戏方框透视,但进入游戏时候鼠标准星对准方框边缘 鼠标光标就会弹出来这是啥情况怎样让光标对准绘制的方框点击鼠标不弹出光标好烦这样
  • ¥20 用Power Query整合的问题
  • ¥20 基于python进行多背包问题的多值编码
  • ¥15 相同型号电脑与配置,发现主板有一台貌似缺少了好多元器件似的,会影响稳定性和使用寿命吗?
  • ¥15 要求编写稀疏矩阵A的转置矩阵的算法
  • ¥15 编写满足以下要求的停车场管理程序,设停车场只有一个可停放n辆车的狭窄通道且只有一个大门可供车辆进出。
  • ¥15 C语言:数据子序列基础版
  • ¥20 powerbulider 导入excel文件,显示不完整
  • ¥15 用keil调试程序保证结果进行led相关闪烁
  • ¥15 paddle训练自己的数据loss降不下去