未定义的偏移量:工作偏移量o后1

时间:2018-06-20 10:59:46

标签: php

我想将相同的值添加到与我编写此代码不同的ID号中,但是在仅将一个值添加到数据库后,它说“未定义的偏移量:1” 她可能会编码

$d = 0;  
$sql="SELECT * FROM  emplyeelist WHERE StatuseUnder = '$EmpIdSE'";  
$result = mysqli_query($db,$sql);

while($row = mysqli_fetch_assoc($result)){
    echo "$row['fullName']"."<input type = 'Checkbox' name = 'EmpName[$d]' value = '".$row['fullName']."'>";  
    ++$d;
}
$size = count($_POST['EmpName']);    
$d = 0; 
while ($d < $size){
    $EmpName = $_POST['EmpName'][$d];  
    $sql = "INSERT INTO ...";
    $result = mysqli_query($db,$sql);  
++$d;
}

1 个答案:

答案 0 :(得分:0)

我终于把鳕鱼换成了这个

<?php
$d = 0;
$sql="SELECT * FROM  emplyeelist WHERE StatuseUnder = '$EmpIdSE'"; 
$result = mysqli_query($db,$sql);
while($row = mysqli_fetch_assoc($result)){
echo "<input type = 'text' readonly name = 'EmpName[$d]' value ='".$row['fullName']."'>".
"<input type = 'checkbox' readonly name = 'CheckBoxEmpName[$d]' value = '".$row['fullName']."'>"."</br>";
++$d;}
 ?>

$d = 0; 
while ($d < $size){
$EmpName = $_POST['EmpName'][$d];
$CheckBoxEmpName = isset( $_POST['CheckBoxEmpName'][$d]) $_POST['CheckBoxEmpName'][$d] : "";
if(!empty($CheckBoxEmpName)){
$sql = "INSERT INTO  table_name (table_row_name)VALUES ('$EmpName')";
$result = mysqli_query($db,$sql);
}++$d;}

than全部完成了所有工作