如何使用单个提交按钮和动作制作多个表单

时间:2010-10-09 15:18:45

标签: php forms

而是逐个输入一天的课程/减少,我想一次输入10个表格。

HTML就是这样的。

所有表单都做同样的事情,在数据库中添加start_time,finish_time和instructor。

但是我不知道该怎么做。而且我不确定这个HTML是否正确。

任何意见都将受到赞赏。

提前致谢。

HTML

<?php
$date = "2010-10-08";
?>
<form name="form1" method="post" action="inputform.php">
    <!-- form 1 -->
<label for='start_time'>1. Start Time</label>
<input type="text" name="start_time" />
<label for='finish_time'>Finish Time</label>
<input type="text" name="finish_time" />
<label for='instructor'>Instructor</label>
<select name="instructor">
<option value="john">John</option>
<option value="mary">Mary</option>
<option value="jim">Jim</option>
</select>
<input type="hidden" name="date" value="<?php echo $date; ?>"/>
<div style="clear: both;">&nbsp;</div>
<!-- form 2 -->

<label for='start_time'>2. Start Time</label>
<input type="text" name="start_time" />
<label for='finish_time'>Finish Time</label>
<input type="text" name="finish_time" />
<label for='instructor'>Instructor</label>
<select name="instructor">
<option value="john">John</option>
<option value="mary">Mary</option>
<option value="jim">Jim</option>
</select>
<input type="hidden" name="date" value="<?php echo $date; ?>"/>
<div style="clear: both;">&nbsp;</div>

<!-- form 3 -->

<label for='start_time'>3. Start Time</label>
<input type="text" name="start_time" />
<label for='finish_time'>Finish Time</label>
<input type="text" name="finish_time" />
<label for='instructor'>Instructor</label>
<select name="instructor">
<option value="john">John</option>
<option value="mary">Mary</option>
<option value="jim">Jim</option>
</select>
<input type="hidden" name="date" value="<?php echo $date; ?>"/>
<div style="clear: both;">&nbsp;</div>
<!-- form 4,5,6,7,8,9,10 -->


<input type="submit" name="submit" value="Submit" />
</form>

1 个答案:

答案 0 :(得分:0)

您不能一次提交多个表格。 只有一个表单具有特定于表单的方法/操作。

然而,可能需要的是数组。

你可以做点什么

<form ...>
<select name="instructor[]">
...
</select>
<select name="instructor[]">
...
</select>

然后你会得到一个你可以循环的数组。 只需打印$_POST print_r($_POST);就可以看到结构,然后你会看到