I am trying to get data from two joined tables,From one table I am collecting list heading and from second joined table i am collecting list data.
Code for Model:
function view_searching_type_items()
{
$this->db->select("searching_type.searchtype_name, search_type_item.st_item_id_pk, search_type_item.searchtype_itemname");
$this->db->from('searching_type');
$this->db->join('search_type_item', 'search_type_item.st_id_fk = searching_type.st_id_pk');
$query = $this->db->get();
return $query->result_array();
}
Controller:
$url1 = 'http://localhost/pakistanmenu/index.php/Restaurant/ViewSearchingTypeItems';
$curl_hand = curl_init($url1);
curl_setopt($curl_hand, CURLOPT_TIMEOUT, 5);
curl_setopt($curl_hand, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($curl_hand, CURLOPT_RETURNTRANSFER, true);
$data1 = curl_exec($curl_hand);// json_decode($data)
curl_close($curl_hand);
$result['searchingtype'] = (array) json_decode($data1,true);
$this->load->view('header');
$this->load->view('index',$result);
$this->load->view('footer');
View Code:
<?php foreach ($searchingtype as $searchingtyp):?>
<ul class="list-group checked-list-box">
<h1 class="page-header leftsidebar-heading"><?php echo $searchingtyp['searchtype_name'];?></h1>
<li class="list-group-item" data-style="button" style="cursor: pointer;">
<span class="state-icon glyphicon glyphicon-unchecked">
</span>
<?php echo $searchingtyp['searchtype_itemname'];?>
<input type="checkbox" class="hidden">
</li>
Kindly check the below image i have shown the output of this code, and also i have draw what output i need thanks, Kindly help me. thanks