I have a problem after inserting some data from array, the insert data works properly. But the Redirect doesn't work, I don't understand the error, because no error message show just the blank page, I have tried and tried until it become habit that makes me tired.
Here is the Function Controller that I use:
public function all() {
$data = array();
$idkelas = $this->input->post('kelas');
$idabsen = $this->input->post('idabsensi');
$idabsen2 = $this->input->post('idabsen');
$id = $this->input->post('idsiswa');
$hadir = $this->input->post('hadir');
$smt = $this->input->post('semester');
$jamke = $this->input->post('jamke');
$count = count($id);
// to absensi
$this->db->query("UPDATE absensi SET jmlhadir = '$count' WHERE idabsensi = '$idabsen2'");
// to absensidetail
for($j=0; $j < (int)($count); $j++) {
$data[] = array(
'idabsensi' => $idabsen[$j],
'idsiswa' => $id[$j],
'statusabsen' => $hadir[$j],
'semester' => $smt[$j],
'jamke' => $jamke[$j]
);
}
return $this->db->insert_batch('absensidetail', $data);
redirect('absensi/absen/pilihkelas/'.$idkelas, 'refresh');
}
This is the View:
<form action="<?php echo base_url()?>absensi/absen/all" method="post">
<input type="submit" class="btn btn-info btn-large" value="ABSENT ALL" />
<table class="table table-striped table-bordered table-condensed">
<thead>
<tr>
<th>No.</th>
<th>No. Induk</th>
<th>Student Name</th>
<th>Gender</th>
<th>State</th>
<th></th>
</tr>
</thead>
<tbody>
<?php $i=0 ?>
<?php foreach($kel as $d):
$i++;
?>
<tr class="list-users">
<td><input type="hidden" name="idsiswa[]" value="<?=$d->idsiswa?>" readonly><?=$d->idsiswa?></td>
<td><input type="hidden" name="hadir[]" value="hadir" readonly><input type="hidden" name="jamke[]" value="<?=$jamke?>" readonly><input type="hidden" name="mapel" value="<?=$idmapel?>" readonly><?=$d->noinduk?></td>
<td><input type="hidden" name="kelas" value="<?=$d->kelas?>" readonly><input type="hidden" name="semester[]" value="<?=$h_getsmt->idsemester?>" readonly><?=$d->namasiswa?></td>
<td><input type="hidden" name="idabsensi[]" value="<?=$d->idabsensi?>" readonly><input type="hidden" name="idabsen" value="<?=$d->idabsensi?>" readonly><?=$d->jeniskelamin?></td><td><span class="label label-unabsent">unabsent</span></td>
<td>
<div class="btn-group">
<a class="btn btn-mini dropdown-toggle" data-toggle="dropdown" href="#">Actions <span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a ><i class="icon-pencil"></i>Press Button<BR>ABSENT ALL First</a></li>
</ul>
</div>
</td></tr>
<?php endforeach ?>
</tbody>
</table>
</form>
I really hope someone can help me. Thank You