我设法将下拉列表中的数据添加到数据库中。我的问题是当我想编辑时,我无法看到我添加的数据库中的值将进入下拉列表。我知道我的问题在于edit_class_view.php文件。
这是我的edit_class_view.php:
<div class="form-group">
<label class="control-label col-lg-2"> School Year-Semester:</label>
<div class="col-lg-4">
<?php
echo form_open('main/editClass');
$options = array(
'' => 'Select School Year and Semester',
'SY 2016-2017 2nd Sem' => 'SY 2016-2017 2nd Sem',
'SY 2017 Summer' => 'SY 2017 Summer',
'SY 2017-2018 1st Sem' => 'SY 2017-2018 1st Sem',
);
echo "<div class='drop_pos'>";
echo form_dropdown('sys', $options, 'class="btn dropdown-toggle"', 'required="required"', 'data-toggle="dropdown-menu"', '<?php echo $row->$School_Year_Semester;?>');
?>
<br>
<div class="text-danger"><?php echo form_error('sys');
</div>
</div>
</div>
</div>
答案 0 :(得分:1)
考虑到您使用的是Codeigniter 3.请参阅form_dropdown的正确语法https://www.codeigniter.com/userguide3/helpers/form_helper.html
您需要进行类似的更改。您在"contextmenu": {
"select_node": false,
"show_at_node": false,
"items": function(node) {
$.ajax({
url: 'some_url_with_actions_for_node',
success: function (action_list) {
return action_list;
}
})
}
}
$ row-&gt; $ School_Year_Semester 它应该是 $ row-&gt; School_Year_Semester
<?php echo $row->$School_Year_Semester;?>