I want to update a table with with Columns
BEFORE UPDATE
 ROLLNO    NAME     ATTENDANCE     DAY   MONTH    YEAR
  1        Name1    PRESENT        16    04       2016
  2        Name2    PRESENT        16    04       2016
  3        Name3    PRESENT        16    04       2016
After update i am trying to change the attendance to "ABSENT" for everyone
But what happens after updating is
 ROLLNO    NAME     ATTENDANCE     DAY   MONTH    YEAR
  3        Name3    ABSENT         16    04       2016
  3        Name3    ABSENT         16    04       2016
  3        Name3    ABSENT         16    04       2016
here is the code that updates the database. But the problem here is the whole table is filled with the values of the last row when updated. I have echo-ed the values inside foreach to check whether values stored and passed are correct and it is perfect. The problem is while updating it to the DB
foreach ($name_array as $key => $name_values) {
    $name_values = mysqli_real_escape_string($connection,$name_values);
    $roll_values = mysqli_real_escape_string($connection,$roll_array[$key]);
    $att_values = mysqli_real_escape_string($connection,$att_array[$key]);
    echo $name_values."<br>";
    echo $att_values."<br>";
    echo $roll_values."<br>";
    $sql= "UPDATE `aclass10` SET 
                             Name='".$name_values.
                             "',attendance='".$att_values.
                             "',RollNo='".$roll_values.
                             "',day='".$day.
                             "',month='".$month.
                             "',year='".$year.
                             "'WHERE day='".$day."'";
    $result = mysqli_query($connection,$sql);
}
What is the mistake i am making and how to fix it ?
 
     
     
    