更新时间:2023-02-01 11:37:36
您需要将要显示在下拉菜单中的选项放入数组中,就像这样
You need to put the options you want displayed in the drop down into an array, like so
$options = array(
'red' => 'Red',
'green' => 'Green',
'blue' => 'Blue',
);
// The params here are:
// 'color' => name of the drop down
// '$options' => options for the drop down
// 'red' => the selected value of the drop down
echo form_dropdown('color', $options, 'red');
我要做的是在模型中创建一个函数,例如 $ model -> dropdown_options()
并使用它从数据库中获取行并将其放入数组中。
What I would do is create a function in my model, say $model->dropdown_options()
and use that to get the rows from the database and put them into an array.