dongqinta4174 2019-02-13 05:30
浏览 41

当我单击另一个复选框时未定义的索引,如果我单击所有复选框,错误将不会显示

I have some check boxes and if I check only one check box there's an error of undefined index but if I check all there's no error, so basically the index will be defined when there is some value in it, but I only need to check one box but every time I do an error shows up and I cant advance, please help

if (isset($_POST['save12'])){
$ins = $_POST['teacher'];
$subject = $_POST['subject'];
$room = $_POST['room'];
$strand = $_POST['strand'];
$section = $_POST['section'];

$m = $_POST['m'];
$w = $_POST['w'];
$f = $_POST['f'];
$t = $_POST['t'];
$th = $_POST['th'];
}

that's how I defined my checkboxes and this is my checkbox

 <?php
    include '../functions/database.php';
    $sql = "SELECT * FROM time order by 'time_start'";
    $query=mysqli_query($conn,$sql)or die(mysqli_error());

    while($row=mysqli_fetch_array($query)){
        $id=$row['timeID'];
        $start=date("h:i a",strtotime($row['time_start']));
        $end=date("h:i a",strtotime($row['time_end']));

    ?>
     <tr >
                            <td><?php echo $start."-".$end;?></td>
                            <td><input type="checkbox" id="check" name="m[]" value="<?php echo $id;?>" style="width: 20px; height: 20px;"></td>
                            <td><input type="checkbox" id="check" name="t[]" value="<?php echo $id;?>" style="width: 20px; height: 20px;"></td>
                            <td><input type="checkbox" id="check" name="w[]" value="<?php echo $id;?>" style="width: 20px; height: 20px;"></td>
                            <td><input type="checkbox" id="check" name="th[]" value="<?php echo $id;?>" style="width: 20px; height: 20px;"></td>
                            <td><input type="checkbox" id="check" name="f[]" value="<?php echo $id;?>" style="width: 20px; height: 20px;"></td>

                          </tr>

    <?php }?>

it works fine when I click all check boxes but if I only choose one the other 4 will be undefined, thanks in advance

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 sub地址DHCP问题
    • ¥15 delta降尺度计算的一些细节,有偿
    • ¥15 Arduino红外遥控代码有问题
    • ¥15 数值计算离散正交多项式
    • ¥30 数值计算均差系数编程
    • ¥15 redis-full-check比较 两个集群的数据出错
    • ¥15 Matlab编程问题
    • ¥15 训练的多模态特征融合模型准确度很低怎么办
    • ¥15 kylin启动报错log4j类冲突
    • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大