Heim > Fragen und Antworten > Hauptteil
echo <<<'FORM'
<form action="" method="post">
<input type="number" name = "rows">行
<br />
<input type="number" name = "cols">列
<input type="submit" value="提交";
</form>
FORM;
$rows = isset($_POST['rows']) ? $_POST['rows'] : 3;
$cols = isset($_POST['cols']) ? $_POST['cols'] : 3;
// $rows = $_POST['rows'];
// $cols = $_POST['cols'];
echo '<table border=" 1" cellpacing="0" cellpadding="5">';
$i = 0;
while ($i<$rows) {
echo '<tr>';
$j = 0 ;
while ($j<$cols) {
echo '<td>'.($i * $cols + $j).'</td>';
$j++;
}
echo '</tr>';
$i++;
}
echo '</table>';
代码如上,获取不到行和列的数值
清音Susunma~2019-06-20 16:01:32
form 里面的action的值改成当前文件名,就像这样<form action="xx.php" method="post">