doufubian3479 2016-08-10 17:48
浏览 32
已采纳

php - 如何在循环中排除一行代码

I have a code in HTML in a table. And I want the loop to just ignore them

<?php
$sel_admin = "query  ";
$rs_admin = mysql_query($sel_admin);
while($row = mysql_fetch_array($rs_admin))
{      
    echo "<th>". $row['a'].  "</th>";


    </thead> // This two line of code
    <tbody>  // is the one I want to exclude in the while loop


    $sel_admin2 = "query2  ";
    $rs_admin2 = mysql_query($sel_admin2);
    while($row2 = mysql_fetch_array($rs_admin2))
    {
        echo" <tr class='gradeX'> ";
        echo "<td>" . $row2['sched3_time'].  "</td>";
        echo"</tr>";
    }
}
?>

Is this even possible?

  • 写回答

4条回答 默认 最新

  • dongxi3911 2016-08-10 18:09
    关注

    I'm guessing you want those lines printed once, not to be outside the loop, per se. You could use a variable to track it:

    $linesNeeded = true;
    while (...) {
      ...
      if ($linesNeeded) {
        echo $line1;
        echo $line2;
        $linesNeeded = false;
      }
      ...
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 请看一下,学校实验要求,我需要具体代码
  • ¥50 pc微信3.6.0.18不能登陆 有偿解决问题
  • ¥20 MATLAB绘制两隐函数曲面的交线
  • ¥15 求TYPCE母转母转接头24PIN线路板图
  • ¥100 国外网络搭建,有偿交流
  • ¥15 高价求中通快递查询接口
  • ¥15 解决一个加好友限制问题 或者有好的方案
  • ¥15 急matlab编程仿真二阶震荡系统
  • ¥20 TEC-9的数据通路实验
  • ¥15 ue5 .3之前好好的现在只要是激活关卡就会崩溃