Reputation: 5
I'm getting a error when executed the function.
Message: Trying to get property of non-object
Filename: views/create_crpo_view.php
Line Number: 35 (1st echo in the view )
Controller
function index() {
$data['ds_division'] = $this->mcreate_crpo->get_dsdivision();
$this->load->view('header');
$this->load->view('create_crpo_view', $data);
$this->load->view('footer');
}
Model
function get_dsdivision() {
$this->db->select('DSDivisionId');
$this->db->select('ds_division_name');
$this->db->from('ds_division');
$query = $this->db->get();
return $query->result_array();
}
view
<?php
foreach ($ds_division as $row) {
echo '<option value="'.$row->ds_division->DSDivisionId.'">'.$row->ds_division->ds_division_name.'</option>';
}
echo form_dropdown('select', $ds_division, '', 'class="dropdown_box"');
echo form_label('DS division');
echo "<div id = \"radio_list\">";
?>
Upvotes: 0
Views: 1234
Reputation: 1145
You are using an array, not an object. Try this:
echo '<option value="'.$row['DSDivisionId'].'">';
notice that:
result_array
, returns your query as an Array.
result
, returns your query as an Object
for more info visit Generating Query Results on C.I 2.2 or here on C.I 3.0
Upvotes: 0