我正在寫一個表單,其中有一個選擇菜單,我想從數據庫中取出值,所以我認爲這將是沿着這些行的東西:Codeigniter form_helper獲取數據庫行是選擇菜單中的值
我的觀點
<?php
echo form_open('admin/save_content');
echo form_fieldset();
echo form_dropdown('categories', $select_options);
echo form_submit('category_submit', 'Submit');
echo form_fieldset_close();
echo form_close();
?>
我控制器
function add_content() {
$data = array();
$this->is_logged_in();
$this->load->model('category_model');
$data['select_options'] = $this->category_model->get_all_online();
$this->load->view('admin/content/add_content', $data);
}
我的模型
public function get_all_online() {
$this->db->select('*');
$this->db->from('category');
$this->db->where('category_online', 1);
$query = $this->db->get();
return $query->result();
}
現在
,當我放置$selected_options
形式下拉我得到這個錯誤,
遇到一個PHP錯誤
嚴重性:4096
消息:Object類的stdClass的 不能被轉換爲字符串
文件名:幫手/ form_helper.php
行號:331
太傻了,我不得不把明顯的查詢結果有陣後拉出來的查詢 - >結果 – Udders 2009-12-14 16:28:36