doushi1960 2015-07-16 11:20
浏览 35

向动态表添加行号

How to add row number or serial number for dynamically generated table?? This is my code.

echo"<table>";
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>";
}

echo "</table>";
  • 写回答

2条回答 默认 最新

  • dongtiao2105 2015-07-16 11:28
    关注

    try this

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

    </div>
    
    评论

报告相同问题?