i've 3 tables city, information and condition. During my code i have proven the various cites under different condition. what i wish to do is to buy the seperate ids from the metropolitan areas to ensure that i'm able to run some queries during my 'information' table.

My model is offered below:

  function get_status(){
$states = $this->db->get('state');
$like = array();
$status = array();
foreach ($states->result() as $state){
$cities = $this->db->get_where('city', array('state_id'=> $state->id));
$like=$cities->result();
$status=$like[0]->city_id;

   }

    echo $status;
  }

however when i run the code i only obtain the last id from the last city saved underneath the last condition within the the table. for instance the condition 3 has city which has id 3. i am only getting this id. however i want all of the ids from the metropolitan areas like- 1,2,3.

i am using Codeigniter framework.

Thanks ahead of time

$like - it`s an assortment. [] - the very first component of an assortment.

echo $like[0]->city_id;

I haven`t examined it. (In a single iteration -> it requires all of the metropolitan areas from that ID)

 function get_status(){
        $states = $this->db->get('state');
        $like = array();
        $status = array();

    foreach ($states->result() as $state){
        $cities = $this->db->get_where('city', array('state_id'=> $state->id));
            foreach ($cities->result() as &$v){
                echo $v->city_id."<br/>";
            }
            echo "......<br/>";
       }
}