如何使用php codeigniter将多行值添加到数据库中

I'm trying to make a school attendance tracker with codeigniter. I don't know how to get both the Student_no AND the radio button value Present or Absent to enter into the database. The values of student_no and the radio buttons are both being posted as NULL to my controller?

My Controller file

function insertAttendance(){

    $student_no=$this->input->post('student_no');
    $attendance=$this->input->post('attendance');

    $data = array(
        'student_no'=>$student_no,
        'attendance'=>$attendance
        );
    //$this->form_validation->set_data($data);

    $this->db->set($data);
    $this->db->insert('attendance',$data);
}

My view

     <h3>ATTENDANCE TRACKER</h3>
                <table class="table table-lg" name="student_no"> 

                  <tr>
                  <th>Student_NO</th>
                  <th>Student name</th>
                  <th>Student DOB</th>
                  <th>Attendance</th>
                  </tr>

                <?php foreach ($query->result_array() as $row): {?>
                    <tr>
                        <td><?php echo $row['student_no'];?></td>

                        <td><?php echo $row['student_name'];?></td>

                        <td><?php echo $row['student_dob'];?></td>
                <tr>
                    <label>

<label><input type="radio" name="attendance[<?php echo $row['player_id']; ?>]"  value="Yes">Present</label> 
    &emsp;
<label><input type="radio" name="attendance[<?php echo  $row['player_id']; ?>]" value="No">Absent</label>

                    </td> </tr>

                    <?php } ?>

                    <?php endforeach; ?>

                    </tr>
                    </tbody>
                    </table>

Where is the form field for student_no? I don't see it, it should throw an undefined notice. Assuming $row['player_id'] is not empty, $this->input->post('attendance') will not exist.

<input type="radio" name="attendance_<?php echo $row['player_id']; ?>" value="Yes">

Maybe try like this and create a form field for student_no (hidden field?).

You do not need

$this->db->set($data);

as you are already passing the $data array in the insert part of the builder.

EDIT:
I updated the input field code. Put the form tags inside the foreach statement so that each student has its own form.

Each form needs a hidden field to pass along the player_id.

<input type="hidden" name="player_id" value="<?php echo $row['player_id']; ?>">

In the controller, validate POST data and use the player_id you passed through:

$this->input->post('attendance_'. $this->input->post('player_id'))

or similar

EDIT 2:
You can also put the <form> tags outside the foreach statement but then we need to loop through all the POST data in the controller. This allows you to have one submit button on the whole form but does make your backend work more complex.