Passing the array to the view works fine after this line: foreach($rb_data as $row){<table>}?> but in my <body> above the table I am unable to use <h1><?php echo $rb_data['brand'];?></h1>
The error I receive is Message: Undefined index: brand. Ive tried initializing the array using $data = array() in the controller and this has not worked. Is there some other way to initialize the array so it can be used before the foreach statement? Thank you for taking a look.
Controller:
public function community_single($rb){
$data['rb_data'] = $this->rootbeer_model->community_single($rb);
$this->load->view('rb_community_single_view',$data);
}
Model:
public function community_single($rb){
$this->rb_db->select('*');
$this->rb_db->from('rb_selection');
$this->rb_db->where('brand',$rb);
$query = $this->rb_db->get();
return $query->result_array();
}
your
$this->rootbeer_model->community_single($rb);will return an array like this
ie,
rb_data=[[id=>1,value=>'a'],[id=>2,value=>'b'],[id=>3,value=>'c']]so first you need to fetch the row that you wand, using this functions,
then you can access `$row[‘band’]’