我設法從下拉列表添加數據到數據庫。我的問題是當我想編輯時,我無法看到數據庫的值,我添加到下拉菜單中。我知道我的問題在於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>
笨的哪個版本? – Naincy