【发布时间】:2017-03-18 06:10:10
【问题描述】:
我的controller 函数
public function add_books() {
$this->load->model('User');
$data['books'] = $this->User->getAuthor();
$this->load->view('vadd_books',$data);
}
我的user_model 模特
function getAuthor() {
$this->db->select('author_firstname, author_lastname');
$this->db->from('authors');
$query = $this->db->get();
return $query->result();
}
【问题讨论】:
-
如果您的结果不止一个,您需要使用 foreach 循环并将其显示在 html 表格中。
-
在我看来,我已经使用了 foreach。我应该在这里发表我的观点吗?
-
是的,你能发一下吗?
-
能否请您检查一下您是否从您的模型中获得了正确的数据?
-
我从我的模型中得到了正确的数据。我的问题只是显示/使用我的 foreach。
标签: php codeigniter