Codeigniter-重新填充输入字段



我的页面上有一些输入字段,希望在保存时重新填充。这些值被输入到数据库中,我希望这些值在输入字段中得到响应,这样用户就可以看到他们插入了什么。

查看

<div class="col-lg-1">
<label>Test1 </label>
<input type="number" name="ft_ca1[]" min="0" max="10" class="form-control input-sm rounded-0" value="<?php echo $student->ft_scores? $student->ft_scores->ft_ca1: 0; ?>">
</div>

型号

public function get_student_ftscore($subjectId,$sessionId,$sectionId,$classId,$studentId){

$sql = "SELECT mp.id, mp.student_id, mp.class_id, mp.section_id, mp.ft_ca1, mp.ft_ca2, mp.ft_ca3, mp.ft_ca4, mp.ft_ca5, mp.ft_ca6, mp.ft_project, mp.ft_affective, mp.ft_psychomotor, mp.ft_exam, mp.ft_tot_score, mp.created_at, mp.modified_at
FROM ftscores_primary mp
WHERE mp.class_id = ? AND mp.student_id = ? AND mp.section_id = ? AND mp.subject_id = ?  AND mp.session_id = ?
UNION
SELECT mt.id, mt.student_id, mt.class_id, mt.section_id, mt.ft_ca1, mt.ft_ca2, mt.ft_ca3, mt.ft_ca4, mt.ft_ca5, mt.ft_ca6, mt.ft_project, mt.ft_affective, mt.ft_psychomotor, mt.ft_exam, mt.ft_tot_score, mt.created_at, mt.modified_at
FROM ftscores_rn mt
WHERE mt.class_id = ? AND mt.student_id = ? AND mt.section_id = ? AND mt.subject_id = ? AND mt.session_id = ?";
$query = $this->db->query($sql, array($classId, $studentId, $sectionId, $subjectId, $sessionId, $classId, $studentId, $sectionId, $subjectId, $sessionId));
$result = $query->row();
return $result;
}

控制器

public function GetClassStudentsForSubjectft()
{
$class_id = $this->input->post('class_id');
$section_id = $this->input->post('section_id');

$subject_id = $this->input->post('subject_id');

$data['class_id'] = $class_id;
$data['subject_id'] = $subject_id;
$data['section_id'] = $section_id;
$data['subjects'] = $this->subject_model->getAll();
$class = $this->class_model->get();
$data['classlist'] = $class;
$data['session_name'] = $this->setting_model-> getCurrentSessionName();
$session_id = $this->setting_model->getCurrentSession();
$students = $this->student_model->GetClassStudentsForSubjectft($session_id, $class_id, $section_id);

$data['students'] = [];
if(!empty($subject_id)){
foreach($students as $student){
$ftscore = $this->ftprimary_model->get_student_ftscore($subject_id,$session_id,$section_id,$class_id,$student->student_id);

$student->ftscores = $ftscore;
$data['students'][] = $student;
}
}

我建议您使用会话保存带有输入数据的数组,然后在数据成功保存到数据库后重定向回初始页面。您应该检查您的代码点火器版本是否具有闪光消息的概念。这用于保存一些数据,仅用于在页面上以及删除之后。然后在你的表格中,你会检查数据是否设置并且不是null,如果设置了,那么就回显它。如果你只是在学习,我会建议你开始学习代码点火器4。

相关内容

  • 没有找到相关文章

最新更新