Very simple stuff here, I'm new to CI. I have the following:
Model
class Stockists_model extends CI_Model {
public function __construct() {
parent::__construct();
}
function stockists_all() {
return $this->db->get('stockists')->result();
}
}
Controller
$data['stockists'] = $this->Stockists_model->stockists_all();
$this->load->view($this->data['system_settings']['admin_folder'] .'/stockists', $this->data);
View
foreach($stockists as $stockist) {
echo $stockist->Shp_num_an;
echo $stockist->Postcode;
}
But I get the error:
Undefined variable: stockists
and
Invalid argument supplied for foreach()
Can anyone see an issue here?
!empty($stockists)in view beforeforeach loop$this->datathis should be$data