I have a problem. I have a questionnaire site where students participate as respondents to fill out a site question. The problem is that when sending the data contained in the survey results to the database, the data is not written to the database.
this is my table with the name “jawab” as the answer record using the column:
“NIS” as the student identifier
'ID_SOAL' as the question identifier
“JAWABAN” as the student answers
| NIS | ID_SOAL | JAWABAN |
| ... | ....... | ....... |
this table (jawab) is still empty
now in my control code called "soal" as a question controller:
public function index(){
$data['title'] = "Kriteria Rumah Masa Depan yang di Inginkan";
$data['form_action'] = site_url('soal/index');
$data['soals'] = $this->Soal_model->getSoal();
$JAWABAN = $this->input->post('JAWABAN');
$this->Soal_model->InputJawaban($JAWABAN);
$this->load->view('soal/index', $data);
}
my model code named soal_model as a question model:
function getSoal(){
$this->db->select('ID_SOAL, SOAL');
$query = $this->db->get('soal');
if($query->num_rows() > 0){
return $query->result_array();
}
}
function InputJawaban($JAWABAN){
$data = array(
'JAWABAN' => $JAWABAN
); $this->db->insert('jawab',$data);
}
"index":
<body>
<form method="post" action="<?php echo $form_action; ?>">
<table>
<tr>
<th>NO</th>
<th>SOAL</th>
<th>JAWAB</th>
</tr>
<?php $i= 1; ?>
<?php foreach($soals as $soal): ?>
<tr>
<td><?php echo $soal['ID_SOAL']; ?></td>
<td><?php echo $soal['SOAL']; ?></td>
<td><input name="JAWABAN<?php echo $i;?>" type="radio" value="1">YA</input>
<input name="JAWABAN<?php echo $i;?>" type="radio" value="0">TIDAK</input></td>
<?php $i++; ?>
</tr>
<?php endforeach;?>
</table>
<input type="submit" value="KIRIM"/>
</form>
</body>
"YA" "TIDAK"
,
IDEA
| NIS | ID_SOAL | JAWABAN |
| 001 | 1 | Ya |
| 001 | 2 | Ya |
| 001 | 3 | Tidak |
| 001 | 4 | Tidak |
, ,