我正在尝试更新mysql数据库,但我收到一个未定义的偏移通知错误但数据库已更新。 请为此提供解决方案

Updated! Updated!

Notice: Undefined offset: 2 in C:\wamp\www\update1\update.php on line 8
Notice: Undefined offset: 2 in C:\wamp\www\update1\update.php on line 9
Notice: Undefined offset: 2 in C:\wamp\www\update1\update.php on line 10
Notice: Undefined offset: 2 in C:\wamp\www\update1\update.php on line 11
Notice: Undefined offset: 2 in C:\wamp\www\update1\update.php on line 12

Updated!

Notice: Undefined offset: 3 in C:\wamp\www\update1\update.php on line 8
Notice: Undefined offset: 3 in C:\wamp\www\update1\update.php on line 9
Notice: Undefined offset: 3 in C:\wamp\www\update1\update.php on line 10
Notice: Undefined offset: 3 in C:\wamp\www\update1\update.php on line 11
Notice: Undefined offset: 3 in C:\wamp\www\update1\update.php on line 12

Updated!

$size  = array($_POST['NO_OF_CLASSES'],$_POST['NO_OF_CLASSES_PRESENT'],$_POST['NO_OF_CLASSES_ABSENT'],$_POST['PERCENTAGE']);    
$size1 = count($size);
for($i = 0; $i<$size1;$i++) 
{
    $regno = $_POST['REGNO'][$i];
    $Noofclasses= $_POST['NO_OF_CLASSES'][$i];
    $Noofclassespresent= $_POST['NO_OF_CLASSES_PRESENT'][$i];
    $Noofclassesabsent= $_POST['NO_OF_CLASSES_ABSENT'][$i];
    $percentage= $_POST['PERCENTAGE'][$i];
    $query = "UPDATE attendancetbl SET NO_OF_CLASSES='$Noofclasses',NO_OF_CLASSES_PRESENT='$Noofclassespresent',NO_OF_CLASSES_ABSENT='$Noofclassesabsent',PERCENTAGE='$percentage' WHERE REGNO =  '$regno'";
    mysql_query($query) or die ("Error in query: $query");
    echo "<em>Updated!</em><br />";
}

It means that the index of the array you are try to access is not set for example:

$_POST['REGNO'][3] and so on. 

Please, print_r your $size array before the for loop and exit and and you will see what I am talking about

number of records(rows) is minimum compared to the length of the array. So only offset error is occurred. Solution for this count the number of records and write a forloop to manipulate.