0

嘿只是有点奇怪的问题,只是想看看是否有人能在这里发现任何明显的东西。我有一个提交回同一页面的表单,这很好,但是它只提交从“选择组”到“员工”,然后提交和隐藏值,而不是两者之间的复选框。只是不知为什么。让我知道是否需要任何其他细节。

任何帮助将不胜感激!

<div class="maincontent">
  <div class="maincontentinner">
    <div class="row-fluid">
      <div class="span6">
        <div class="widgetbox">
          <h4 class="widgettitle">Enter programme information</h4>
          <div class="widgetcontent">
          <?php
            if(isset($_POST['submit_pressed']))
            {

                $Form_Group = $_POST['group'];
                $Form_Date = $_POST['date'];
                $Form_Start = $_POST['S_time'];
                $Form_Finish = $_POST['F_time'];
                $Form_Staff = $_POST['staff'];
                $Form_Arts = $_POST['Arts'];
                $Form_Media = $_POST['Media'];
                $Form_Personal = $_POST['Personal_Development'];
                $Form_Training = $_POST['Training_Support'];
                $Form_Youth = $_POST['Youth_In_Action'];
                $Form_After = $_POST['After_Schools'];
                $Form_Peer = $_POST['Peer_Education'];
                $Form_Drop = $_POST['Drop_In_Centre'];
                $Form_Arranged = $_POST['One_To_One_Arranged'];
                $Form_Casual = $_POST['One_To_One_Casual'];
                $Form_Residential = $_POST['Residentials'];
                $Form_Kayaking = $_POST['Kayaking'];
                $Form_Bike = $_POST['Bike'];
                $Form_HillWalking = $_POST['Hill_Walking'];
                $Form_Multi = $_POST['Multi_Sports'];

                foreach($_POST['members'] as $value)
                {
                    echo 'Checked: '.$value.'';
                }


            }
          ?>
            <form action="<?php $_SERVER['PHP_SELF']; ?>" method="post">
                <fieldset>
              <p>
                <label>Select Group</label>
                <span class="field">
                <select name="group" class="uniformselect">
                  <option value="">Choose One</option>
                  <?php 
                    $query = mysql_query("SELECT * FROM `GROUP` ORDER BY Group_Name ASC");      

                    //while loop through each of the rows
                    while ($row = mysql_fetch_array($query)) 
                    {  

                        //set variables from the rows
                        $Group_ID = $row['Group_ID'];
                        $Group_Name = $row['Group_Name'];
                ?>
                    <option value="<?php echo $Group_ID; ?>"><?php echo "$Group_Name"; ?></option>
                <?php
                    }
                ?>
                </select>
                </span> </p>
              <div class="par">
                <label>Date Picker</label>
                <span class="field">
                <input id="datepicker" type="date" name="date" class="input-small" />
                </span> </div>
              <div class="par">
                <label>Start Time</label>
                <div class="input-append bootstrap-timepicker">
                  <input id="timepicker1" type="time" class="input-small" name="S_time" />
                  <span class="add-on"><i class="iconfa-time"></i></span> </div>
              </div>
              <div class="par">
                <label>Finish Time</label>
                <div class="input-append bootstrap-timepicker">
                  <input id="timepicker1" type="time" class="input-small" name="F_time" />
                  <span class="add-on"><i class="iconfa-time"></i></span> </div>
              </div>

              <label>Staff Member</label>
              <span class="field">
              <select name="staff" class="uniformselect">
                <option value="">Choose One</option>
                <?php 
                 $query = mysql_query("SELECT * FROM STAFF ORDER BY STAFF_FNAME ASC");      

                //while loop through each of the rows
                while ($row = mysql_fetch_array($query)) 
                {  

                //set variables from the rows
                    $Staff_ID = $row['Staff_ID'];
                    $Staff_FName = $row['Staff_FName'];
                    $Staff_SName = $row['Staff_SName'];
                ?>
                <option value="<?php echo $Staff_ID; ?>"><?php echo "$Staff_FName $Staff_SName"; ?></option>
                <?php
                }
                ?>
              </select>
              </span> </p>
              <br /><br />
              <p>
              <label></label>
              <span class="field">
              </span>
              </p>
          </div>
        </div>
      </div>
      <div class="span6">
        <div class="widgetbox">
          <h4 class="widgettitle">Select applicable programme(s)</h4>
          <div class="widgetcontent">
              <span class="formwrapper">
              <input type="checkbox" name="Media" />
              Media <br />
              <input type="checkbox" name="Arts" />
              Arts <br />
              <input type="checkbox" name="Personal_Development" />
              Personal Development<br />
              <input type="checkbox" name="Training_Support" />
              Training Support <br />
              <input type="checkbox" name="Youth_In_Action" />
              Youth In Action <br />
              <input type="checkbox" name="After_Schools" />
              After Schools <br />
              <input type="checkbox" name="Peer_Education" />
              Peer Education <br />
              <input type="checkbox" name="Drop_In_Centre" />
              Drop In Centre <br />
              <input type="checkbox" name="One_To_One_Arranged" />
              One To One (Arranged)<br />
              <input type="checkbox" name="One_To_One_Casual" />
              One To One (Casual)<br />
              <input type="checkbox" name="Residentials" />
              Residentials <br />
              <input type="checkbox" name="Kayaking" />
              Kayaking <br />
              <input type="checkbox" name="Bike" />
              Bike <br />
              <input type="checkbox" name="Hill_Walking" />
              Hill Walking <br />
              <input type="checkbox" name="Multi_Sports" />
              Multi Sports <br />
              </span>
          </div>
        </div>
      </div>
    </div>
    <div class="widgetbox">
        <h4 class="widgettitle">Enter participating members</h4>
    <script type="text/javascript">
jQuery(document).ready(function(){
    // dynamic table
    jQuery('#dyntable').dataTable({
        "sPaginationType": "full_numbers",
        "aaSortingFixed": [[0,'asc']],
        "fnDrawCallback": function(oSettings) {
            jQuery.uniform.update();
        }
    });

    jQuery('#dyntable2').dataTable( {
        "bScrollInfinite": true,
        "bScrollCollapse": true,
        "sScrollY": "300px"
    });



});

            <table id="dyntable" class="table table-striped responsive">
                <!--table table-bordered responsive
                <colgroup>
                    <col class="con0" style="align: center;/>
                    <col class="con1" />
                    <col class="con0" />
                    <col class="con1" />
                    <col class="con0" />
                    <col class="con1" />
                    <col class="con0" />
                    <col class="con1" />
                    <col class="con0" />
                    <col class="con1" />
                    <col class="con0" />
                    <col class="con1" />
                    <col class="con0" />
                    <col class="con1" />
                </colgroup>-->
                <thead>
                    <tr>
                      <th class="head0 nosort"><input type="checkbox" class="checkall" /></th>
                        <th class="head0">M-ID</th>
                        <th class="head1">Name</th>
                        <th class="head0">Surname</th>
                        <th class="head1">Gender</th>                            
                        <th class="head0">Address</th>
                        <th class="head1">Postcode</th>
                        <th class="head0">Contact</th>
                        <th class="head1">Email</th>
                        <th class="head0">MedCon</th>
                    </tr>
                </thead>
                <tbody>
    <?php 

    //set up the query
    $query = mysql_query("SELECT * FROM MEMBER ORDER BY MEMBER_FNAME ASC");     

    //while loop through each of the rows
    while ($row = mysql_fetch_array($query)) 
    {  

    //set variables from the rows
        $Member_ID=$row['Member_ID'];
        $Member_FName=$row['Member_FName'];
        $Member_SName=$row['Member_SName'];
        $Member_Gender=$row['Member_Gender'];
        $Member_Address=$row['Member_Address'];
        $Member_Postcode=$row['Member_Postcode'];
        $Member_ContactNo=$row['Member_ContactNo'];
        $Member_Email=$row['Member_Email'];
        $Member_Medcon=$row['Member_MedCon'];


    ?>  

                      <td class="aligncenter">
                        <span class="center">
                            <input type="checkbox" name="members[]" value="<?php echo "$Member_ID"; ?>" />
                        </span>
                      </td>
                        <td><?php echo $Member_ID ?></td>
                        <td><?php echo $Member_FName ?></td>
                        <td><?php echo $Member_SName ?></td>
                        <td><?php echo $Member_Gender ?></td>                            
                        <td><?php echo $Member_Address ?></td>
                        <td><?php echo $Member_Postcode ?></td>
                        <td><?php echo $Member_ContactNo ?></td>
                        <td><?php echo $Member_Email ?></td>
                        <td><?php echo $Member_Medcon ?></td>                                                
                    </tr>
     <?php
    }
    ?>

                </tbody>
            </table>
            <br />
            <div align="right">
            <input type="hidden" value="TRUE" name="submit_pressed">
            <input type="submit" name="submit" value="Submit" class="btn btn-primary">
            </div>
            </fieldset>
            </form>
4

1 回答 1

1

您的复选框设置错误。应该是这样的:

<input type="checkbox" name="programs[]" value="Media" />

因此,当用户选择多个复选框时,它们将被放入 $_POST[ 'programs' ] 而不是尝试单独访问每个复选框。

于 2013-10-29T12:58:09.380 回答