[英]How to get and display database table value in codeigniter error was coming
我是新的Codeigniter開發人員,遇到錯誤。 我已經在數據庫中存儲了一些值,並希望在視圖頁面中顯示它。 請幫幫我。
調節器
function get_user_value() {
$data['query'] = $this->user_m->user_data_set($query);
$this->load->view('user_settings', $data); }
模型
public function user_details()
{
// $query = $this->db->select('*')->from('user')->get();
$query = $this->db->get('user');
return $query->$result();
}
嘗試以下操作:注意首先將模型調用到控制器,然后首先添加此函數_construct()
function __construct() {
parent::__construct();
$this->load->model("model_file_name", "model_name_alias");
//Example $this->load->model("user_model","user");
//the "user_model" is the file name in your model folder
}
function get_user_value() {
$data['query'] = $this->model_name_alias->user_details();
$this->load->view('user_settings', $data);
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.