I dont know if my logic is incorrect but I cant get my form_dropdown (down down list) list to populate with data from my database.
The error i get is Undefined property: stdClass::$name.
Code bellow.
My Array in $appertisers when print_r($appertisers);
Array ( [0] => stdClass Object ( [product] => Marinated mixed olives ) [1] => stdClass Object ( [product] => Simons ) [2] => stdClass Object ( [product] => Test ) )
View
$array = array();
foreach($appertisers as $row ){
$array = $row->name;
}
echo form_dropdown('appetisers', $array);
?>
Model
class Get_data extends CI_Model{
function getAppertisers(){
$query = $this->db->query("SELECT product FROM products WHERE cat = 1");
return $query->result();
}
}
Controller
public function index()
{
$this->load->helper('url');
$data = array();
$this->load->model("get_data");
$data['appertisers'] = $this->get_data->getAppertisers();
$this->load->view('header');
$this->load->view('content_contact', $data);
}