如何为动态生成的表添加行号或序列号? 这是我的代码。
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>";
答案 0 :(得分:0)
试试这个
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>";
答案 1 :(得分:0)
echo"<table>";
for($tr=1;$tr<=$rows;$tr++){
echo "<tr>";
for($td=1;$td<=$cols;$td++){
echo "<td>row: ".$tr."</td>";
echo "<td><input type='text' name='bhk'></td>";
}
echo "</tr>";
}
echo "</table>";