多个提交按钮在我的表单中不起作用

时间:2018-10-03 07:25:26

标签: php codeigniter

我正在使用3个提交按钮:
-第一个按钮,用于根据下拉列表搜索值
-第二个按钮,仅更新值
-第三个按钮,用于下载pdf文件。
我的表格应该是

<?php
include("config/config.php");
include("header.php");
?>
<?php 
if (!empty($_POST['mailing-submit'])) {
  Query1;
  query2;
  query3;
} else if (!empty($_POST['contact-submit'])) {
  update query;
} else {
  $sheet_no = 202565;
  header('Location: print_details.php?num='.$sheet_no);
}
?>


<!DOCTYPE html>
<html lang="en">
<div class="page-content">
  <div class="ace-settings-container" id="ace-settings-container">
    <div class="btn btn-app btn-xs btn-warning ace-settings-btn" id="ace-settings-btn">
      <i class="ace-icon fa fa-cog bigger-130"></i>
    </div>
  </div>
  <!-- /.ace-settings-container -->
  <div class="page-header"></div>
  <!-- /.page-header -->

  <form name="mailinglist" method="post">
    <td>
      Drop down list from query1;
    </td>
    <td align="center">
      <input name="mailing-submit" type="submit" id="btnSubmit" value="Submit" class="last btn btn-info" />
    </td>
    <br />
    <br />
    <div class="row">
      <div class="col-xs-12">
        <div class="table-header">
          Staff Details
        </div>

        <br />
        <div class="form-group">
          input item : 1 values from query2;
        </div>
        &nbsp;
        <div class="form-group">
          input item : 2 values from query2;

        </div>
      </div> &nbsp;
      <div class="form-group">
        input item : 3 values from query2;
      </div>
    </div>&nbsp;
    <div class="form-group">
      input item : 4 values from query2;
    </div>
</div> &nbsp;


<div class="form-group">
  input item : 5 values from query2;
</div>
</div>

</form>
</div>

<br />



<form name="contactus" method="post">
  <div class="row">
    <div class="col-xs-12">
      <div class="table-header">
        Bank Details
      </div>
      <br />

      <div class="form-group">
        input item : 1 values from query3;
      </div>
    </div>
    &nbsp;
    <div class="form-group">
      input item : 2 values from query3;
    </div>
  </div> &nbsp;
  <div class="form-group">
    input item : 3 values from query3;
  </div>
  </div> &nbsp;
  <div class="form-group">
    input item : 4 values from query3;
  </div>
  </div>


  </div>

  </div>



  <br />
  <div class="row">
    <div class="col-xs-12">
      <div class="table-header">
        Assistant Examiner Claim
      </div>
      <div>
        <table id="dynamic-table" class="table table-striped table-bordered table-hover">
          <thead>
            <tr>
              <th>Sno</th>
              <th>value1</th>
              <th>value2.</th>
              <th>value3</th>
              <th>value4</th>
              <th>value5</th>
              <th>value6</th>

            </tr>
          </thead>

          <tbody>
            <?php
            $i=1;    
            while($row = mysql_fetch_array($query_omr1)) {    
            ?>
              <tr>
                <td>
                  <?php echo $i++;?>
                </td>
                <td>
                  <?php echo $row['value1'];?>
                </td>
                <td>
                  <?php echo $row['value2'];?>
                </td>
                <td>
                  <?php echo $row['value3'];?>
                </td>
                <td>
                  <?php echo $row['value4'];?>
                </td>
                <td>
                  <?php echo $row['value5'];?>
                </td>
                <td>
                  <?php echo $row['value6'];?>
                </td>

              </tr>
              <?php }?>
          </tbody>
        </table>
      </div>
    </div>
  </div>
</form>
</div>
<!-- /.page-content -->

</div>

<td align="center"><input type="text" style="width:100px" name="grand_total" id="grand_total" /></td>

<div align="center">
  <input name="contact-submit" type="submit" id="editpdf_submit" value="Update" style="padding:5px" class="btn btn-danger" />&nbsp;&nbsp;&nbsp;

</div>

<div align="center">
  <input name="download" type="submit" id="download" value="Update & Download PDF" style="padding:5px" class="btn btn-danger" />&nbsp;&nbsp;&nbsp;

</div>
</div>
<!-- /.main-content -->
</body>
</html>

那些提交按钮不起作用。我在编码中犯了什么错误。当我更改为关闭标签时,将不会显示任何输出。如何纠正错误?

1 个答案:

答案 0 :(得分:0)

您的提交按钮不起作用,因为您在按钮之前关闭了表单。

像这样更改代码:

<?php
            include("config/config.php");
            include("header.php");


            ?>
            <?php 

            if (!empty($_POST['mailing-submit'])) {

            Query1;
            query2;
            query3;

            }
            else if (!empty($_POST['contact-submit'])) {

            {
                update query;
            }
            else {

                $sheet_no = 202565;
                header('Location: print_details.php?num='.$sheet_no);

            }
            ?>

            <div class="page-content">
                <div class="ace-settings-container" id="ace-settings-container">
                    <div class="btn btn-app btn-xs btn-warning ace-settings-btn" id="ace-settings-btn">
                        <i class="ace-icon fa fa-cog bigger-130"></i>
                    </div>


                </div><!-- /.ace-settings-container -->

                <div class="page-header">

                </div><!-- /.page-header -->



                <form name="mailinglist" method="post">

                                        <td>
                                        Drop down list from query1;
                                        </td>


                                            <td align="center"><input name="mailing-submit" type="submit" id="btnSubmit" value="Submit" class="last btn btn-info"/></td>

                <br />
                <br />


                        <div class="row">
                            <div class="col-xs-12">
                                <div class="table-header">
                                    Staff Details 
                                </div>

                            <br />  
                            <div class="form-group">
                                input  item : 1 values from query2;
                            </div>
                            &nbsp;
                            <div class="form-group">
                                input  item : 2 values from query2;

                                </div>
                            </div> &nbsp;   
                            <div class="form-group">
                                input  item : 3 values from query2;
                                </div>
                            </div>&nbsp;
                            <div class="form-group">
                                input  item : 4 values from query2;
                                </div>
                            </div> &nbsp;


                            <div class="form-group">
                            input  item : 5 values from query2;
                            </div>                                  
                            </div>                      

                                         </div>

                <br />



        <form name="contactus" method="post">
                                <div class="row">
                                            <div class="col-xs-12">
                                                <div class="table-header">
                                                    Bank Details 
                                                </div>
                                <br />

                            <div class="form-group">
                                input  item : 1 values from query3;
                                </div>
                            </div>
                            &nbsp;
                            <div class="form-group">
                                input  item : 2 values from query3;
                                </div>
                            </div> &nbsp;
                            <div class="form-group">
                                input  item : 3 values from query3;
                                </div>
                            </div> &nbsp;
                            <div class="form-group">
                                input  item : 4 values from query3;
                                </div>
                            </div>          


                            </div>                                  

                    </div>



            <br />
                        <div class="row">
                            <div class="col-xs-12">
                                <div class="table-header">
                                    Assistant Examiner Claim 
                                </div>




                                <div>


                                <table id="dynamic-table" class="table table-striped table-bordered table-hover">
                                <thead>
                                            <tr>
                                                <th>Sno</th>
                                                <th>value1</th>
                                                <th>value2.</th>
                                                <th>value3</th>
                                                <th>value4</th>
                                                <th>value5</th>
                                                <th>value6</th>

                                            </tr>
                                        </thead>

                                        <tbody>
                                        <?php 
                                        $i=1;

                                        while($row = mysql_fetch_array($query_omr1)) { 

                                                    ?>
                                        <tr>
                                        <td><?php echo $i++;?></td>
                                        <td><?php echo $row['value1'];?></td>
                                        <td><?php echo $row['value2'];?></td>
                                        <td><?php echo $row['value3'];?></td>
                                        <td><?php echo $row['value4'];?></td>
                                        <td><?php echo $row['value5'];?></td>
                                        <td><?php echo $row['value6'];?></td>

                                        </tr>
                                        <?php }?>
                                        </tbody>
                                        </table>


                                </div>
                            </div>
                        </div>


                                        </div><!-- /.page-content -->

                                    </div>

                            <td align="center"><input type="text"  style="width:100px" name="grand_total" id="grand_total" /></td>

                            <div align="center">
            <input name="contact-submit" type="submit" id="editpdf_submit" value="Update" style="padding:5px" class="btn btn-danger" />&nbsp;&nbsp;&nbsp;

            </div>  

            <div align="center">
            <input name="download" type="submit" id="download" value="Update & Download PDF" style="padding:5px" class="btn btn-danger" />&nbsp;&nbsp;&nbsp;

            </div>   </form>                       
                        </div><!-- /.main-content -->


                </body>
            </html>