Welcome Guest, Not a member yet? Register   Sign In
Unable to pass variable from one function to another function
#4

[eluser]scm22ri[/eluser]
Hi guys,

Thanks for both of your responses and help.

This is how I corrected the problem.

The below syntax result passes an array (result()) but I put it in a foreach statement and returned it as a single string
Code:
$this->db->select('state');
  $this->db->from('dealers');
  $this->db->where('id',$id);
  $query = $this->db->get();
  
  foreach($query->result() as $row){
   $data = $row->state;
  }
  return $data;

The syntax in my controller. The below single can be converted into a variable because I'm passing a string. I can also pass an array (which I was doing before) but that's where my problem was.

Code:
$state = $this->Dealer_data->get_state_from_the_id($id); // gets the state

On my view
Code:
foreach($simInfo as $getState){
                                      $state = $getState->state;
                                      echo $state;
    }

Thanks for the help everyone


Messages In This Thread
Unable to pass variable from one function to another function - by El Forum - 01-26-2014, 02:09 PM



Theme © iAndrew 2016 - Forum software by © MyBB