获取复选框的值到其他页面

时间:2017-04-01 11:50:45

标签: php

我有这段代码:

                <table class="table table-bordered">
                <thead>
                  <tr>
                    <th class="thheader">Monday</th>
                    <th class="thheader">Tuesday</th>
                    <th class="thheader">Wednesday</th>
                    <th class="thheader">Thursday</th>
                    <th class="thheader">Friday</th>
                  </tr>
                </thead>
          <?php
          $available = array();
          while ($row3 = mysqli_fetch_assoc($result3))
          {

              $dayt = $row3['day_of_week'];
              $times = $row3['time_window_label'];
              $tt= explode(",",$times);
              $available[$dayt][] = trim($tt[1]);

          }
      for ($x=0; $x<3; $x++)
      {
        ?>
   <tr>
    <td>
     <center>
<?php 
      if($available[1][$x] != ''){ 
      $counter++;?>
      <input type="checkbox" class="colour-button choice1 daypicker1" day="1" name="val1" value="<?php echo @$tt[1]?>" id="btn112<?php echo $counter;?>" /><label for="btn112<?php echo $counter;?>"> <i class="fa fa-check-circle hide12" id="chk-btn112<?php echo $counter;?>"></i>  <?php echo @$available[1][$x];?></label>
      <?php }?>
     </center>
   </td>
   <td>
     <center>
      <?php if($available[2][$x] != ''){
      $counter++;?>
      <input type="checkbox" class="colour-button choice2 daypicker2" day="2" name="val2" value="<?php echo @$tt[1]?>" id="btn1012<?php echo $counter;?>" /><label for="btn1012<?php echo $counter;?>"> <i class="fa fa-check-circle hide13" id="chk-btn1012<?php echo $counter;?>"></i>  <?php echo @$available[2][$x];?></label>
      <?php }?>  
     </center>
   </td>
   <td>
    <center>
      <?php if($available[3][$x] != ''){
      $counter++;?>
      <input type="checkbox" class="colour-button choice3 daypicker3" day="3" name="val3" value="<?php echo @$tt[1]?>" id="btn102<?php echo $counter;?>" /><label for="btn102<?php echo $counter;?>"> <i class="fa fa-check-circle hide14" id="chk-btn102<?php echo $counter;?>"></i>  <?php echo @$available[3][$x];?></label>
      <?php }?>  
    </center>
  </td>
   <td>
    <center>
      <?php if($available[4][$x] != ''){
      $counter++;?>
      <input type="checkbox" class="colour-button choice4 daypicker4" day="4" name="val4" value="<?php echo @$tt[1]?>" id="btn1032<?php echo $counter;?>" /><label for="btn1032<?php echo $counter;?>"> <i class="fa fa-check-circle hide15" id="chk-btn1032<?php echo $counter;?>"></i>  <?php echo @$available[4][$x];?></label>
      <?php }?>  
    </center>
   </td>
   <td>
    <center>
      <?php if($available[5][$x] != ''){
      $counter++;?>
      <input type="checkbox" class="colour-button choice5 daypicker5" day="5" name="val5" value="<?php echo @$tt[1]?>" id="btn1042<?php echo $counter;?>" /><label for="btn1042<?php echo $counter;?>"> <i class="fa fa-check-circle hide16" id="chk-btn1042<?php echo $counter;?>"></i>  <?php echo @$available[5][$x];?></label>
      <?php }?>  
    </center>
   </td>
 </tr>
    <?php }?>
</table>

它位于表单中,当我单击提交时,我希望能够获取表单中的值。我面临的问题是我的行是动态的,例如这是我的结果: enter image description here 这些是复选框,用户每天只能选择一个。但是,当我发送表单时,这就是我尝试获取值的方式:

$value1 = $_POST['val1'];
$value2 = $_POST['val2'];
$value3 = $_POST['val3'];
$value4 = $_POST['val4'];
$value5 = $_POST['val5'];

echo $value1;die;

然而,我的输出一直只是上午5点到8点,即使我选择它也不会是上午9点到下午12点。它总是第一次出现在行上。我该如何解决这个问题?

0 个答案:

没有答案