这是我的表格,您可以在下面的表格中看到,在1 column
我们可以输入2 values
,我的问题是如何获得该值并将其放入正确的{{1} }}
select option
这是我的选择选项,你可以看到我有4种不同的选择或你称之为下拉菜单,当我点击编辑按钮时,我想将第一个 No | Course_Code | Course_Score |
1 | CC001,CC002 | A, B |
2 | CC003, | C, |
放入正确的位置course_code
选择并将course_code
放入正确的课程分数,我该怎么做?
这就是我如何在我的表中添加2个值以及我的函数来获取course_score
Course
这是我的观点
public function save(id=null){
'Course_code'=>$this->input->post("course_code1").', '.$this->input->post("course_code2"),
'Course_Score'=>$this->input->post("course_score1").', '.$this->input->post("course_score2")
}
public function combo_course(){
//GET ALL COURSE LIST
$kodePro = $this->input->post('pro_id');//09
$matkulCombo = $this->cms_matakuliah_m->getMatkul($this->session->userdata('kodePS'))->result();
$list_combo = "";
$list_combo .= "<option value='0'>Choose</option>";
foreach($matkulCombo as $rows):
$list_combo .="<option value='".$rows->Course_code."'>".$rows->Course_name."</option>";
endforeach;
echo $list_combo;
}
答案 0 :(得分:0)
使用表单助手然后传递默认值
echo form_dropdown('course_code1', $get_matkul, $currentValue, "id='courseCode' class='input-large'");
答案 1 :(得分:0)
<?php
// $get_matkul is course codes from database table. right?
$get_scores = mysqli_fetch_array($result);//(a,b,c,d,...) from table
$Course_codes = explode(',',$matkul->Course_code);
$Course_Scores = explode(',',$matkul->Course_Score);?>
<select id="courseCode" class="form-control">
<option value="">Choose</option>
<?php foreach($get_matkul as $rows):
$selected = "";
foreach($Course_codes as $Course_code){
if($Course_code == $rows->Course_code){
$selected = "Selected";
}
}?>
<option value="<?php echo $rows->Course_code?>" <?php echo $selected;?> >
<?php echo $rows->Course_name ?>
</option>
<?php endforeach; ?>
</select>
<select disabled id="cScore" class="form-control">
<option value="">Choose</option>
<?php foreach($get_scores as $score):
$selected = "";
foreach($Course_Scores as $Course_Score){
if($Course_Score == $score->Course_Score){
$selected = "Selected";
}
}?>
<option value="<?php echo $score->Course_Score;?>" <?php echo $selected ?>><?php echo $score->Course_Score;?></option>
<?php endforeach; ?>
</select>