这里非常简单,我是CI的新手。我有以下内容:
模型
class Stockists_model extends CI_Model {
public function __construct() {
parent::__construct();
}
function stockists_all() {
return $this->db->get('stockists')->result();
}
}
控制器
$data['stockists'] = $this->Stockists_model->stockists_all();
$this->load->view($this->data['system_settings']['admin_folder'] .'/stockists', $this->data);
查看
foreach($stockists as $stockist) {
echo $stockist->Shp_num_an;
echo $stockist->Postcode;
}
但我收到错误:
未定义的变量:stockists
和
为foreach()提供的参数无效
有人能在这里看到问题吗?
答案 0 :(得分:2)
如果您正在$data['stocklists]
获取数据
$this->load->view($this->data['system_settings']['admin_folder'] .'/stockists',array('data'=>$data));
和其他页面上的数据转发数据
$stocklists=$data['stocklists'];
如果你在$data['stocklists']
祝你好运!!