gpt4 book ai didi

php - 如何根据使用select的输入编辑id_semester的值?

转载 作者:行者123 更新时间:2023-11-29 17:54:18 25 4
gpt4 key购买 nike

我的函数将 Controller 添加到模型

$data['edit'] = $this->pengumuman->getEdit($id_pengumuman);

我在模型上的函数 getEdit

$this->db->select('mp.id_pengumuman, mp.judul_pengumuman, mp.isi_pengumuman, mp.start_date, mp.end_date, 
mp.thn_ajaran, mp.id_semester, mb.beasiswa, mp.date_created, mp.user_created, mp.is_publish')
->from('tbl_mst_pengumuman mp')
->join('tbl_mst_beasiswa mb', 'mp.id_beasiswa=mb.id_beasiswa', 'left')
->group_by('mp.id_pengumuman')
->where('mp.id_pengumuman', $id_pengumuman);
return $this->db->get()->row();

查看我的表单

<div class="form-group">
<div class="col-sm-12">
<label>Semester<span class="required">*</span></label>
<select name="id_semester" id="id_semester" class="form-control input-sm">
<option value="0">--Pilih Semester--</option>
<option value="1" <?= ($edit->id_semester == @$edit->id_semester) ? "selected":""; ?>>Ganjil</option>
<option value="2" <?= ($edit->id_semester == @$edit->id_semester) ? "selected":""; ?>>Genap</option>
</select>
</div>
</div>

id_semester 中,值 1 = 奇数,2 = 偶数。问题是当id_semester的编辑值无法正确显示时。所有 ID 显示 2 = 偶数。

最佳答案

在 View 上,修复条件,以便它选择正确的id_semester:

<div class="form-group">
<div class="col-sm-12">
<label>Semester<span class="required">*</span></label>
<select name="id_semester" id="id_semester" class="form-control input-sm">
<option value="0">--Pilih Semester--</option>
<option value="1" <?= ($edit->id_semester == '1') ? "selected":""; ?>>Ganjil</option>
<option value="2" <?= ($edit->id_semester == '2') ? "selected":""; ?>>Genap</option>
</select>
</div>
</div>

关于php - 如何根据使用select的输入编辑id_semester的值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49001423/

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