this welcome controller code:
public function index() { $data = array(); $data['title'] = '। user ।'; $data['logo_image'] = $this->sv_model->select_logo_image(); $data['all_footer'] = $this->sv_model->select_all_published_footer(); $data['all_welcome'] = $this->sv_model->select_all_published_welcome(); $data['all_notification'] = $this->sv_model->select_all_published_notification(); $data['all_chairman_gallery_image'] = $this->sv_model->select_all_chairman_gallery_image(); $data['all_gallery_image'] = $this->sv_model->select_all_gallery_image(); $data['all_country'] = $this->sv_model->select_all_country(); $data['all_district'] = $this->sv_model->select_all_district(); $data['all_user'] = $this->sv_model->select_all_user(); //echo '<pre>'; //print_r($data); // exit(); $this->load->view('welcome_message', $data); }
i have 2 tables in database called 'tbl_country' , 'tbl_district'
tbl_countrycontains 2 field(country_id,country_name) tbl_district contains 3 field(district_id,country_id,district_name)
now want view 'country name' 'main menu' , 'district name 'sub_menu'.. should call in view? have used foreach() loop view main menu, can't submenu.
my model:
public function select_all_district() { $this->db->select('*'); $this->db->from('tbl_district'); $query_result = $this->db->get(); $result = $query_result->result(); return $result; }
you call foreach country. in foreach, have call again foreach districts..
there 2 possibilities. have ordered them in array country_id index
$country_id = $country['country_id']; foreach($all_district[$country_id] $district) { echo $district['district_name']; }
or second way check every district if match against country_id (from upper menu/country
foreach($all_district $district) { if($district['country_id'] == $country['id]) { echo $district['district_name']; } }
maybe can give structure of array? or model? have in view?
Comments
Post a Comment