2010-10-09 31 views
0

而不是一天一個一個的輸入/減少一天,我想一次輸入10個表單。如何使用單個提交按鈕和使用php的動作製作多個表格

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> 

回答

0

你不能一次提交多個表單。 只有一種形式具體的方法/行動。

但是可能需要的是數組。

,你可以這樣做

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

,那麼你將得到一個數組,通過張貼,你可以循環。 只需看看$_POST,如print_r($_POST);,然後你會看到

相關問題