gpt4 book ai didi

php - 插入批处理 codeigniter 后重定向不起作用

转载 作者:行者123 更新时间:2023-11-29 00:04:14 25 4
gpt4 key购买 nike

我从数组中插入一些数据后遇到问题,插入数据工作正常。但是重定向不起作用,我不明白错误,因为没有错误消息只显示空白页面,我试了又试,直到它成为让我厌倦的习惯。

这是我使用的功能 Controller :

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');

}

这是 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>

我真的希望有人能帮助我。谢谢你

最佳答案

重定向需要在 return 之前进行

这是来自 php.net :

If called from within a function, the return statement immediately ends execution of the current function, and returns its argument as the value of the function call. return also ends the execution of an eval() statement or script file.

您还可以查看:How to make a redirect in PHP?

关于php - 插入批处理 codeigniter 后重定向不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28280444/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com