禁用自动生成的表中的列

时间:2015-07-15 10:53:32

标签: php

这是我自动生成的表格 我想根据条件值隐藏或显示第一行我是如何实现的?

for($tr=1;$tr<=$rows;$tr++){
    echo "<tr>";
    for($td=1;$td<=$cols;$td++){
        //  echo "<td>row: ".$tr." column: ".$td."</td>";
         echo "<td><input type='text' name='bhk'></td>";
    }
    echo "</tr>";
}

2 个答案:

答案 0 :(得分:1)

for($tr=1;$tr<=$rows;$tr++){
    if($tr != 1){ // put your condition between the () on this line
         echo "<tr>";
         for($td=1;$td<=$cols;$td++){
             //  echo "<td>row: ".$tr." column: ".$td."</td>";
             echo "<td><input type='text' name='bhk'></td>";
         }
    }
    echo "</tr>";
}

答案 1 :(得分:0)

for($tr=1;$tr<=$rows;$tr++) { if(<your condition>){continue;}//this will skip the current row echo ""; for($td=1;$td<=$cols;$td++) {// echo "row: ".$tr." column: ".$td.""; echo ""; } echo ""; }

希望这会对你有所帮助。