代码之家  ›  专栏  ›  技术社区  ›  shin

如何用php实现单提交按钮和动作的多表单

  •  0
  • shin  · 技术社区  · 15 年前

    我宁愿一天一节课一张地输入,也不愿一次输入10张表格。

    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 回复  |  直到 15 年前
        1
  •  0
  •   The Surrican    15 年前

    不能同时提交多个表单。 只有一个窗体具有特定于窗体的方法/操作。

    你可以这样做

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

    然后你会得到一个你可以循环通过的数组。 $_POST 喜欢 print_r($_POST);

    推荐文章