Codeigniter form_helper getting database rows to be values in select menu

后端 未结 6 2116
借酒劲吻你
借酒劲吻你 2021-01-07 00:49

I am writing a form, which has a select menu in it, I want the values to pulled from the database, so I thought it would be something along these lines:

My view

6条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-07 01:42

    In your view, you can add foreach there instead of in Model.

    result_array() as $row){
       $data[$row['id']]=$row['name'];
       echo form_dropdown('categories', $row);
       }
       echo form_submit('category_submit', 'Submit');
       echo form_fieldset_close();
       echo form_close();
    ?>
    

    Not tested.

提交回复
热议问题