codeigniter가있는 학교 출근 추적기를 만들려고합니다. Student_no와 라디오 버튼 값 Present 또는 Absent를 데이터베이스에 입력하는 방법을 모르겠습니다. student_no 및 라디오 버튼의 값은 모두 내 컨트롤러에 NULL로 게시되고 있습니까?PHP codeigniter를 사용하여 데이터베이스에 행 값을 여러 개 추가하는 방법
내 컨트롤러 파일
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);
}
내보기 양식 필드가 student_no입니다
<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>
 
<label><input type="radio" name="attendance[<?php echo $row['player_id']; ?>]" value="No">Absent</label>
</td> </tr>
<?php } ?>
<?php endforeach; ?>
</tr>
</tbody>
</table>
이 코드가 HTML에서 'name = "attendance php echo $ row ['student_no '];?>"'를 생성하는 브라우저에서'page source'를보십시오. 그러면 적어도 하나의 실수가 있음을 알아야합니다 – RiggsFolly
"name"속성 안에 공백을 넣지 마십시오. "현재"라디오 버튼의 "이름"속성에는 "출석"과 학생 사이에 공백이 포함되어 있습니다. – alpadev
@RiggsFolly 감사합니다. 그래서 '출석'의 마지막에 학생 번호를 붙이고 있습니다 :/그것을 제거하면 두 행 사이에서 4 개의 라디오 버튼 중 하나만 선택할 수 있습니다. newb에 대한 제안 사항이 있습니까? – Glen