1
我對此很新,所以請耐心等待。如何在php和html中創建乘法表
我以某種方式需要下表有HTML代碼,將創建一個兩列和三行的表。左上角的列將有標題行,中間將有列,底部將有一個提交按鈕,這樣,當您向右列添加數字時,即將10放在行文本框中,將10放在列文本框中,並將a將創建10 X 10的乘法表。
我有以下PHP和HTML代碼,但它們不能一起工作。請幫忙!
我以爲我可以讓HTML代碼在PHP文檔中工作。
該html代碼應該有兩個文本框,一個用於行,一個用於列,當您將一個數字添加到行和列時,它將創建一個大的乘法表。
<form name="table" id="table" action="table.php" method="post">
<h2>Table Generator</h2>
<p>
<label for="width">Rows:</label>
<input type="text" name="Width" id="Width" />
</p>
<p>
<label for="height">Columns:</label>
<input type="text" name="height" id="height" />
</p>
<input name="sbt" type="submit" formaction="table.php" onClick="MM_validateForm ('width','','RisNum','height','','RisNum');return document.MM_returnValue" value="Calculate" />
</form>
<?php
$rows = $_POST ['width'];
$columns = $_POST ['height'];
$width = 5;
$height = 6;
$i=1;
$table='<table border="1">';
for($r=0;$r<$width;$r++)
{
$table .= '<tr>';
for($c=0;$c<$height;$c++)
{
$table .= "<td>$i</td>";
$i++;
}
$table .= '<tr>';
}
$table .= '</table>';
echo $table;
?>
有趣的是,這個問題得到了upvote而一半的代碼是不可見的。 – faintsignal
你能顯示你的輸出嗎? –
那麼你有什麼具體問題。 –