1

I want to show the content of a table but instead of sec_id I want to show the sec_name by passing the sec_id in other function and get the sec_name and show it on the view. But I can not concatenate the variable sec_name because the last sec_name is show instead of all other sec_name.

This is the model

function get_subsec(){
$q=$this->db->query("SELECT subsec_id,subsec_name,order,role_id,sec_id FROM subsection");
return $q->result_array();
}

function show_secname($id){
$q=$this->db->query("SELECT name FROM section WHERE sec_id=".$id);
return $q->result_array();
}

This is the controller.

function get_subsec(){
$data["x"]=$this->amodel->get_subsec();
foreach($data["x"] as $s){
$y["k"]=$this->amodel->show_secname($s["sec_id"]);
}
$this->load->view("get_subsec",array_merge($data,$y));
}

This is the view

<?php foreach($x as $row){ 
echo $row["subsec_id"];
echo $row["subsec_name"];
echo $row["order"];
}?>
<?php foreach($k as $i){
echo $i["name"];
}?>
Jenz
  • 8,280
  • 7
  • 44
  • 77
A.S
  • 11
  • 1

0 Answers0