我想在html中创建一个关于用户输入的行数和列数的表


I want to create a table in html with respect to the no.of rows and no.of columns entered by user

我想在html中创建一个关于用户输入的行数和列数的表。。

有人能帮我提供代码吗…

为了将来的参考,我建议您包含您所尝试的代码片段;我们不仅可以提供进一步的帮助,而且还将使您的知识进一步受益。

我很快就完成了一些代码,它还没有经过测试,所以如果它不起作用,我很抱歉。下面的代码假设已经提交了一个表单,并且已经用行的名称设置了一个变量,另一个将关闭。

<?php
$rows = isset($_POST["rows"]) ? $_POST["rows"] : 0; // get the number of rows submitted
$cols = isset($_POST["cols"]) ? $_POST["cols"] : 0; // get the number of cols submitted
?>
<!DOCTYPE html>
<html>
<body>
    <table>
    <?php
    // begin to create the table - rows first
    for ($row = 0; $row < $rows; $row++) { ?>
        <tr>
        <?php for ($col = 0; $col < $cols; $col++) { ?>
            <td></td>
        <?php } // end cols for loop ?>
        </tr>
    <?php } // end rows for loop ?>
    </table>
</body>
</html>

我希望我已经正确地理解了这个问题,这个答案证明是有帮助的。