I can’t retrieve values from $info (as stated below) in CodeIgniter View.
Here is the scenario:
I explained everything the code.
function info() {
{...} //I retrieve results from database after sending $uid to model.
$dbresults = $this->my_model->get_info($uid); //Assume that this model returns some value.
foreach($dbresults as $row) {
$info = $row->address; //This is what I need to produce the results
$results = $this->my_model->show_info($info);
return $results; //This is my final result which can't be achieved without using $row->address. so first I have to call this in my controller.
}
// Now I want to pass it to a view
$data['info'] = $results;
$this->load->view('my_view', $data);
//In my_view, $info contains many values inherited from $results which I need to call one by one by using foreach. But I can't use $info with foreach because it is an Invalid Parameter as it says in an error.
using
$resultinsideforeachis not reasonable. Because in each loop $result will take a new value. So, preferably use it as anarrayand then pass it to your view. Besides, you should not usereturninsideforeach.to check what $result array has do
var_export($result);orvar_dump($result);after the end offoreach. and make sure that this is what you want to send to your view.Now, in your view you can do: