tags:

views:

58

answers:

1

Rather inputing one by one for a class/lessen for a day, I'd like to input 10 forms at once.

The HTML is something like this.

All the form do the same thing, add start_time, finish_time and instructor in a database.

However I am not sure how to do this. And I am not sure if this HTML is correct or not.

Any inputs will be appreciated.

Thanks in advance.

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>
A: 

you cannot submit multiple forms at once. only one form with the form specific method/action.

however what probably need are arrays.

you can do something like

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

then you will get an array posted which you can loop through. just look at the structure by printing out $_POST like print_r($_POST); then you'll see

Joe Hopfgartner