【发布时间】:2016-05-21 16:24:12
【问题描述】:
我正在尝试创建一个下拉列表,其中包含我的数据库中的项目。
我有它填充,但值最终成为数组中的位置。即:0、1、2等。
这是我的表单代码:
echo form_open('main/generate_report');
$depts = array();
foreach ($my_depts->result() as $row)
{
$depts[] = $row->DEPT_NAME;
}
echo form_dropdown('dept_select', $depts);
echo form_submit('report_submit', 'Generate Report');
提交的时候转到这个函数:
echo '<h1><u>Report</u></h1>';
echo '<h2>';
echo $this->input->post('dept_select');
echo '</h2>';
例如,当我选择名为“test”的第一个选项时,它会输出 0(它在数组中的位置),而不是像我想要的那样输出“test”。
填充下拉列表时如何调整值?
提前谢谢你。
我正在使用 Codeigniter 3。
【问题讨论】:
标签: php forms codeigniter