【发布时间】:2012-07-08 13:51:38
【问题描述】:
我是新来的。我有问题,很着急:( 场景:我想做一个动态输入表单。用户输入他们想要的许多列和行。然后,它生成表格作为以前表格中输入的数字。之后,用户在表格中输入一个随机数,然后单击提交按钮。系统将记录数据并进行处理。最后,系统会显示平均值(只是示例)。
表生成成功。问题是如何保存/读取输入表单中输入的数据。
这是 input.php
<tr>
<td width="30%" align="left" valign="top">Input the number of columns :<td height="37" align="left" valign="top"><input type="text" name="colums" value="" /></td>
</tr>
<tr>
<td align="left" valign="top">Input the number of rows :</td>
<td width="70%" align="left" valign="top"><input type="text" name="rows" value="" /></td>
</tr>
<tr>
<td align="left" valign="top"> </td>
<td align="left" valign="top"><input type="submit" name="button" id="button" value="Submit" /></td>
</tr>
</table>
</form>
这样的结果 php..
<?php
$columns = $_POST['columns'];
$rows = $_POST['rows'];
echo "<form method='post' action='process.php'>";
echo "<table>";
//made the rows
for ($i= 0; $i <= $rows-1; $i++){
//and the colums
echo "<tr>";
for ($j = 0; $j <= $colums-1; $j++) {
//here is the input form, and each of data inputed here that i want to save it.
$sum = array('[$i][$j]');
echo "<td> </td>
<td><input size='5' type='text' name='data".$sum."' /></td>
";
}
echo "</tr>";
}
echo "<tr><td></td><td><input type='submit' name='submit' values='Submit' /></td></tr>";
//im not sure here in value='$sum'
echo "<tr><td></td><td><input type='hidden' name='banyak' value='$sum' /></td></tr>";
echo "</table>";
echo "</form>";
// here,which one should i $_GET[''] ?
?>
并且 process.php 显示数据的平均值。我在 process.php 中完全错误
【问题讨论】:
-
哦,你“非常着急”!这意味着你终于可以支付我的薪水了!
-
如果我有足够的钱,我不会在这里问。
-
对不起,我总是先搜索再问。现在我没有看到任何解决方案。感谢您的链接。
标签: php arrays forms input multidimensional-array