How to display the child record related to the parent record?










0















I am using CodeIgniter and data table with child row. I have a table and records are: -



id| Name | role | leaders
1 | A | 1 | 1
2 | B | 2 | 1
3 | C | 2 | 1
4 | D | 3 | 2
5 | E | 3 | 2
6 | F | 4 | 3
7 | G | 4 | 3


Note: leaders value are the id value.



Now I have to display the parent records which the role is 1,2,3.
Like I have Name A,B,C,D,E with roles are 1,2,2,3,3



A, B, C, D, E records are displaying like parent records and I have to display the child record related to the leader's id.



print_r($books_of_secondary)


enter image description here



For example: A is the parent and child records are B, C. Same as on B is the parent and child are D and E. C is the parent and child are F and G So my output is like below



id| Name | role | leaders
1 | A | 1 | 1
|
|->B | 2 | 1
|->C | 2 | 1

2 | B | 2 | 1
|
|->D | 3 | 2
|->E | 3 | 2

3 | c | 2 | 1
|
|->F | 4 | 3
|->G | 4 | 3

4 | D | 3 | 2
|
|-> NO records

5 | E | 3 | 2
|
|-> NO records


I tried some code which is



Controller



public function team_members_get()
$draw = intval($this->input->get("draw"));
$start = intval($this->input->get("start"));
$length = intval($this->input->get("length"));
$books = $this->Employee_model->getTotalList_of_TeamLeader();

$data['draw'] = 1;
$data['recordsTotal'] = count($books);
$data['recordsFiltered'] = count($books);
foreach ($books as $key => $row)

$encryption_id=base64_encode($this->encryption->encrypt($row->id));
$arr_result = array(
// "Sr.No" => $n,
"id" => $encryption_id,
"TLname" => $row->firstname.' ' .$row->lastname,
"emp_role_name" => $row->emp_role_name,
"emp_teamLeader" => $row->team_leadername,

);
$array_secondary = array();
$books_of_secondary = $this->Employee_model->getTotalList_of_TeamLeader_employee($row->team_leadername);
foreach ($books_of_secondary as $key => $row)


$arr_result2 = array(
"t_id" => base64_encode($this->encryption->encrypt($row->id)),
"t_name" => $row->firstname.' ' .$row->lastname,
"t_emp_role_name" => $row->emp_role_name,
"t_emp_teamLeader" => $row->team_leadername
);
$array_secondary = $arr_result2;

$arr_result['secondary'] = $array_secondary;
$data['data'] = $arr_result;

echo json_encode($data);
exit;



Model



public function getTotalList_of_TeamLeader()
$get_member ="access_role IN(1,2,3) AND is_archive=0";
$this->db->select('*');
$this->db->from('tbl_employee');
$this->db->where($get_member);
$query = $this->db->get();
$res = $query->result();
return $res;

public function getTotalList_of_TeamLeader_employee($team_leadername)
$this->db->select('*');
$this->db->from('tbl_employee');
$this->db->where('team_leadername',$team_leadername);
$query = $this->db->get();
$res = $query->result();
return $res;



Js



 function format(d) 
// d is the original data object for the row var val;
if(d.secondary.length == 0)
return "There are no Team members";

var display = '<table cellpadding="5" cellspacing="0" border="0" width="100%">';

for (val of d.secondary)
var s_action_set="<a href='' class='edit_color s_icon_set tooltip_'><img src='"+baseUrl+"/assets/images/icons/pending.png'><span class=tooltiptext_>Edit</span></a>";
display += '<tr><td width="2%"></td>' + '<td>' + val.t_name + '</td>' + '<td>' + val.t_emp_role_name + '</td>'+ '</td>' + '<td>' + val.t_emp_teamLeader + '</td>'+ '</tr>';

display += '</table>';
return display;


$(document).ready(function()
var oTable =$('#team_members_list').DataTable(
"responsive": true,
"paging": true,
"pageLength" : 10,
"ajax":
"url": baseUrl+ "/Employee_control/team_members_get",
"type": "POST"
,
"columns": [
"data": "TLname" ,
"data": "emp_role_name" ,
"data": "emp_teamLeader" ,
],
);
$('#team_members_list tbody').on('click', 'td.details-control', function ()
var tr = $(this).closest('tr');
var row = oTable.row( tr );

if ( row.child.isShown() )
// This row is already open - close it
row.child.hide();
tr.removeClass('shown');

else
// Open this row
row.child( format(row.data()) ).show();
tr.addClass('shown');

//$('[data-toggle="tooltip"]', tr.next('tr')).tooltip();

);
);









share|improve this question
























  • I am able to display the parent records but child records are not displaying proper.

    – user9437856
    Nov 13 '18 at 12:13











  • Do print_r on $books_of_secondary for debugging the cause.

    – Adder
    Nov 13 '18 at 12:58











  • @Adder, give me time to update the Response

    – user9437856
    Nov 13 '18 at 13:13











  • @Adder, I updated the question. I added an image because it's too long. I commented [0] in first two.

    – user9437856
    Nov 13 '18 at 13:33
















0















I am using CodeIgniter and data table with child row. I have a table and records are: -



id| Name | role | leaders
1 | A | 1 | 1
2 | B | 2 | 1
3 | C | 2 | 1
4 | D | 3 | 2
5 | E | 3 | 2
6 | F | 4 | 3
7 | G | 4 | 3


Note: leaders value are the id value.



Now I have to display the parent records which the role is 1,2,3.
Like I have Name A,B,C,D,E with roles are 1,2,2,3,3



A, B, C, D, E records are displaying like parent records and I have to display the child record related to the leader's id.



print_r($books_of_secondary)


enter image description here



For example: A is the parent and child records are B, C. Same as on B is the parent and child are D and E. C is the parent and child are F and G So my output is like below



id| Name | role | leaders
1 | A | 1 | 1
|
|->B | 2 | 1
|->C | 2 | 1

2 | B | 2 | 1
|
|->D | 3 | 2
|->E | 3 | 2

3 | c | 2 | 1
|
|->F | 4 | 3
|->G | 4 | 3

4 | D | 3 | 2
|
|-> NO records

5 | E | 3 | 2
|
|-> NO records


I tried some code which is



Controller



public function team_members_get()
$draw = intval($this->input->get("draw"));
$start = intval($this->input->get("start"));
$length = intval($this->input->get("length"));
$books = $this->Employee_model->getTotalList_of_TeamLeader();

$data['draw'] = 1;
$data['recordsTotal'] = count($books);
$data['recordsFiltered'] = count($books);
foreach ($books as $key => $row)

$encryption_id=base64_encode($this->encryption->encrypt($row->id));
$arr_result = array(
// "Sr.No" => $n,
"id" => $encryption_id,
"TLname" => $row->firstname.' ' .$row->lastname,
"emp_role_name" => $row->emp_role_name,
"emp_teamLeader" => $row->team_leadername,

);
$array_secondary = array();
$books_of_secondary = $this->Employee_model->getTotalList_of_TeamLeader_employee($row->team_leadername);
foreach ($books_of_secondary as $key => $row)


$arr_result2 = array(
"t_id" => base64_encode($this->encryption->encrypt($row->id)),
"t_name" => $row->firstname.' ' .$row->lastname,
"t_emp_role_name" => $row->emp_role_name,
"t_emp_teamLeader" => $row->team_leadername
);
$array_secondary = $arr_result2;

$arr_result['secondary'] = $array_secondary;
$data['data'] = $arr_result;

echo json_encode($data);
exit;



Model



public function getTotalList_of_TeamLeader()
$get_member ="access_role IN(1,2,3) AND is_archive=0";
$this->db->select('*');
$this->db->from('tbl_employee');
$this->db->where($get_member);
$query = $this->db->get();
$res = $query->result();
return $res;

public function getTotalList_of_TeamLeader_employee($team_leadername)
$this->db->select('*');
$this->db->from('tbl_employee');
$this->db->where('team_leadername',$team_leadername);
$query = $this->db->get();
$res = $query->result();
return $res;



Js



 function format(d) 
// d is the original data object for the row var val;
if(d.secondary.length == 0)
return "There are no Team members";

var display = '<table cellpadding="5" cellspacing="0" border="0" width="100%">';

for (val of d.secondary)
var s_action_set="<a href='' class='edit_color s_icon_set tooltip_'><img src='"+baseUrl+"/assets/images/icons/pending.png'><span class=tooltiptext_>Edit</span></a>";
display += '<tr><td width="2%"></td>' + '<td>' + val.t_name + '</td>' + '<td>' + val.t_emp_role_name + '</td>'+ '</td>' + '<td>' + val.t_emp_teamLeader + '</td>'+ '</tr>';

display += '</table>';
return display;


$(document).ready(function()
var oTable =$('#team_members_list').DataTable(
"responsive": true,
"paging": true,
"pageLength" : 10,
"ajax":
"url": baseUrl+ "/Employee_control/team_members_get",
"type": "POST"
,
"columns": [
"data": "TLname" ,
"data": "emp_role_name" ,
"data": "emp_teamLeader" ,
],
);
$('#team_members_list tbody').on('click', 'td.details-control', function ()
var tr = $(this).closest('tr');
var row = oTable.row( tr );

if ( row.child.isShown() )
// This row is already open - close it
row.child.hide();
tr.removeClass('shown');

else
// Open this row
row.child( format(row.data()) ).show();
tr.addClass('shown');

//$('[data-toggle="tooltip"]', tr.next('tr')).tooltip();

);
);









share|improve this question
























  • I am able to display the parent records but child records are not displaying proper.

    – user9437856
    Nov 13 '18 at 12:13











  • Do print_r on $books_of_secondary for debugging the cause.

    – Adder
    Nov 13 '18 at 12:58











  • @Adder, give me time to update the Response

    – user9437856
    Nov 13 '18 at 13:13











  • @Adder, I updated the question. I added an image because it's too long. I commented [0] in first two.

    – user9437856
    Nov 13 '18 at 13:33














0












0








0








I am using CodeIgniter and data table with child row. I have a table and records are: -



id| Name | role | leaders
1 | A | 1 | 1
2 | B | 2 | 1
3 | C | 2 | 1
4 | D | 3 | 2
5 | E | 3 | 2
6 | F | 4 | 3
7 | G | 4 | 3


Note: leaders value are the id value.



Now I have to display the parent records which the role is 1,2,3.
Like I have Name A,B,C,D,E with roles are 1,2,2,3,3



A, B, C, D, E records are displaying like parent records and I have to display the child record related to the leader's id.



print_r($books_of_secondary)


enter image description here



For example: A is the parent and child records are B, C. Same as on B is the parent and child are D and E. C is the parent and child are F and G So my output is like below



id| Name | role | leaders
1 | A | 1 | 1
|
|->B | 2 | 1
|->C | 2 | 1

2 | B | 2 | 1
|
|->D | 3 | 2
|->E | 3 | 2

3 | c | 2 | 1
|
|->F | 4 | 3
|->G | 4 | 3

4 | D | 3 | 2
|
|-> NO records

5 | E | 3 | 2
|
|-> NO records


I tried some code which is



Controller



public function team_members_get()
$draw = intval($this->input->get("draw"));
$start = intval($this->input->get("start"));
$length = intval($this->input->get("length"));
$books = $this->Employee_model->getTotalList_of_TeamLeader();

$data['draw'] = 1;
$data['recordsTotal'] = count($books);
$data['recordsFiltered'] = count($books);
foreach ($books as $key => $row)

$encryption_id=base64_encode($this->encryption->encrypt($row->id));
$arr_result = array(
// "Sr.No" => $n,
"id" => $encryption_id,
"TLname" => $row->firstname.' ' .$row->lastname,
"emp_role_name" => $row->emp_role_name,
"emp_teamLeader" => $row->team_leadername,

);
$array_secondary = array();
$books_of_secondary = $this->Employee_model->getTotalList_of_TeamLeader_employee($row->team_leadername);
foreach ($books_of_secondary as $key => $row)


$arr_result2 = array(
"t_id" => base64_encode($this->encryption->encrypt($row->id)),
"t_name" => $row->firstname.' ' .$row->lastname,
"t_emp_role_name" => $row->emp_role_name,
"t_emp_teamLeader" => $row->team_leadername
);
$array_secondary = $arr_result2;

$arr_result['secondary'] = $array_secondary;
$data['data'] = $arr_result;

echo json_encode($data);
exit;



Model



public function getTotalList_of_TeamLeader()
$get_member ="access_role IN(1,2,3) AND is_archive=0";
$this->db->select('*');
$this->db->from('tbl_employee');
$this->db->where($get_member);
$query = $this->db->get();
$res = $query->result();
return $res;

public function getTotalList_of_TeamLeader_employee($team_leadername)
$this->db->select('*');
$this->db->from('tbl_employee');
$this->db->where('team_leadername',$team_leadername);
$query = $this->db->get();
$res = $query->result();
return $res;



Js



 function format(d) 
// d is the original data object for the row var val;
if(d.secondary.length == 0)
return "There are no Team members";

var display = '<table cellpadding="5" cellspacing="0" border="0" width="100%">';

for (val of d.secondary)
var s_action_set="<a href='' class='edit_color s_icon_set tooltip_'><img src='"+baseUrl+"/assets/images/icons/pending.png'><span class=tooltiptext_>Edit</span></a>";
display += '<tr><td width="2%"></td>' + '<td>' + val.t_name + '</td>' + '<td>' + val.t_emp_role_name + '</td>'+ '</td>' + '<td>' + val.t_emp_teamLeader + '</td>'+ '</tr>';

display += '</table>';
return display;


$(document).ready(function()
var oTable =$('#team_members_list').DataTable(
"responsive": true,
"paging": true,
"pageLength" : 10,
"ajax":
"url": baseUrl+ "/Employee_control/team_members_get",
"type": "POST"
,
"columns": [
"data": "TLname" ,
"data": "emp_role_name" ,
"data": "emp_teamLeader" ,
],
);
$('#team_members_list tbody').on('click', 'td.details-control', function ()
var tr = $(this).closest('tr');
var row = oTable.row( tr );

if ( row.child.isShown() )
// This row is already open - close it
row.child.hide();
tr.removeClass('shown');

else
// Open this row
row.child( format(row.data()) ).show();
tr.addClass('shown');

//$('[data-toggle="tooltip"]', tr.next('tr')).tooltip();

);
);









share|improve this question
















I am using CodeIgniter and data table with child row. I have a table and records are: -



id| Name | role | leaders
1 | A | 1 | 1
2 | B | 2 | 1
3 | C | 2 | 1
4 | D | 3 | 2
5 | E | 3 | 2
6 | F | 4 | 3
7 | G | 4 | 3


Note: leaders value are the id value.



Now I have to display the parent records which the role is 1,2,3.
Like I have Name A,B,C,D,E with roles are 1,2,2,3,3



A, B, C, D, E records are displaying like parent records and I have to display the child record related to the leader's id.



print_r($books_of_secondary)


enter image description here



For example: A is the parent and child records are B, C. Same as on B is the parent and child are D and E. C is the parent and child are F and G So my output is like below



id| Name | role | leaders
1 | A | 1 | 1
|
|->B | 2 | 1
|->C | 2 | 1

2 | B | 2 | 1
|
|->D | 3 | 2
|->E | 3 | 2

3 | c | 2 | 1
|
|->F | 4 | 3
|->G | 4 | 3

4 | D | 3 | 2
|
|-> NO records

5 | E | 3 | 2
|
|-> NO records


I tried some code which is



Controller



public function team_members_get()
$draw = intval($this->input->get("draw"));
$start = intval($this->input->get("start"));
$length = intval($this->input->get("length"));
$books = $this->Employee_model->getTotalList_of_TeamLeader();

$data['draw'] = 1;
$data['recordsTotal'] = count($books);
$data['recordsFiltered'] = count($books);
foreach ($books as $key => $row)

$encryption_id=base64_encode($this->encryption->encrypt($row->id));
$arr_result = array(
// "Sr.No" => $n,
"id" => $encryption_id,
"TLname" => $row->firstname.' ' .$row->lastname,
"emp_role_name" => $row->emp_role_name,
"emp_teamLeader" => $row->team_leadername,

);
$array_secondary = array();
$books_of_secondary = $this->Employee_model->getTotalList_of_TeamLeader_employee($row->team_leadername);
foreach ($books_of_secondary as $key => $row)


$arr_result2 = array(
"t_id" => base64_encode($this->encryption->encrypt($row->id)),
"t_name" => $row->firstname.' ' .$row->lastname,
"t_emp_role_name" => $row->emp_role_name,
"t_emp_teamLeader" => $row->team_leadername
);
$array_secondary = $arr_result2;

$arr_result['secondary'] = $array_secondary;
$data['data'] = $arr_result;

echo json_encode($data);
exit;



Model



public function getTotalList_of_TeamLeader()
$get_member ="access_role IN(1,2,3) AND is_archive=0";
$this->db->select('*');
$this->db->from('tbl_employee');
$this->db->where($get_member);
$query = $this->db->get();
$res = $query->result();
return $res;

public function getTotalList_of_TeamLeader_employee($team_leadername)
$this->db->select('*');
$this->db->from('tbl_employee');
$this->db->where('team_leadername',$team_leadername);
$query = $this->db->get();
$res = $query->result();
return $res;



Js



 function format(d) 
// d is the original data object for the row var val;
if(d.secondary.length == 0)
return "There are no Team members";

var display = '<table cellpadding="5" cellspacing="0" border="0" width="100%">';

for (val of d.secondary)
var s_action_set="<a href='' class='edit_color s_icon_set tooltip_'><img src='"+baseUrl+"/assets/images/icons/pending.png'><span class=tooltiptext_>Edit</span></a>";
display += '<tr><td width="2%"></td>' + '<td>' + val.t_name + '</td>' + '<td>' + val.t_emp_role_name + '</td>'+ '</td>' + '<td>' + val.t_emp_teamLeader + '</td>'+ '</tr>';

display += '</table>';
return display;


$(document).ready(function()
var oTable =$('#team_members_list').DataTable(
"responsive": true,
"paging": true,
"pageLength" : 10,
"ajax":
"url": baseUrl+ "/Employee_control/team_members_get",
"type": "POST"
,
"columns": [
"data": "TLname" ,
"data": "emp_role_name" ,
"data": "emp_teamLeader" ,
],
);
$('#team_members_list tbody').on('click', 'td.details-control', function ()
var tr = $(this).closest('tr');
var row = oTable.row( tr );

if ( row.child.isShown() )
// This row is already open - close it
row.child.hide();
tr.removeClass('shown');

else
// Open this row
row.child( format(row.data()) ).show();
tr.addClass('shown');

//$('[data-toggle="tooltip"]', tr.next('tr')).tooltip();

);
);






php jquery html5 datatables codeigniter-3






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 13 '18 at 13:32







user9437856

















asked Nov 13 '18 at 12:12









user9437856user9437856

449212




449212












  • I am able to display the parent records but child records are not displaying proper.

    – user9437856
    Nov 13 '18 at 12:13











  • Do print_r on $books_of_secondary for debugging the cause.

    – Adder
    Nov 13 '18 at 12:58











  • @Adder, give me time to update the Response

    – user9437856
    Nov 13 '18 at 13:13











  • @Adder, I updated the question. I added an image because it's too long. I commented [0] in first two.

    – user9437856
    Nov 13 '18 at 13:33


















  • I am able to display the parent records but child records are not displaying proper.

    – user9437856
    Nov 13 '18 at 12:13











  • Do print_r on $books_of_secondary for debugging the cause.

    – Adder
    Nov 13 '18 at 12:58











  • @Adder, give me time to update the Response

    – user9437856
    Nov 13 '18 at 13:13











  • @Adder, I updated the question. I added an image because it's too long. I commented [0] in first two.

    – user9437856
    Nov 13 '18 at 13:33

















I am able to display the parent records but child records are not displaying proper.

– user9437856
Nov 13 '18 at 12:13





I am able to display the parent records but child records are not displaying proper.

– user9437856
Nov 13 '18 at 12:13













Do print_r on $books_of_secondary for debugging the cause.

– Adder
Nov 13 '18 at 12:58





Do print_r on $books_of_secondary for debugging the cause.

– Adder
Nov 13 '18 at 12:58













@Adder, give me time to update the Response

– user9437856
Nov 13 '18 at 13:13





@Adder, give me time to update the Response

– user9437856
Nov 13 '18 at 13:13













@Adder, I updated the question. I added an image because it's too long. I commented [0] in first two.

– user9437856
Nov 13 '18 at 13:33






@Adder, I updated the question. I added an image because it's too long. I commented [0] in first two.

– user9437856
Nov 13 '18 at 13:33













1 Answer
1






active

oldest

votes


















0














you have to write self join query.



select te.name as leaderName,te1.name as childName from tbl_employee as te join tbl_employee as te1 on te.id = te1.leaders



this query gives you leader name with child name.






share|improve this answer























  • Yes, it's displaying but I am using CodeIgniter and data tables with child row. datatables.net/examples/api/row_details.html. I have to display like this.

    – user9437856
    Nov 13 '18 at 13:38











  • You have to include a JS library and add for loop to display table row

    – bimal sharma
    Nov 13 '18 at 15:31











  • There is no issue with JS. I already added. My scenario is different. Can you make jsfiddle for me for better understand?

    – user9437856
    Nov 13 '18 at 15:51











  • Better you create on demo in jsfiddle and shre with me. I will check and update you on same.

    – bimal sharma
    Nov 14 '18 at 6:50










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53280772%2fhow-to-display-the-child-record-related-to-the-parent-record%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














you have to write self join query.



select te.name as leaderName,te1.name as childName from tbl_employee as te join tbl_employee as te1 on te.id = te1.leaders



this query gives you leader name with child name.






share|improve this answer























  • Yes, it's displaying but I am using CodeIgniter and data tables with child row. datatables.net/examples/api/row_details.html. I have to display like this.

    – user9437856
    Nov 13 '18 at 13:38











  • You have to include a JS library and add for loop to display table row

    – bimal sharma
    Nov 13 '18 at 15:31











  • There is no issue with JS. I already added. My scenario is different. Can you make jsfiddle for me for better understand?

    – user9437856
    Nov 13 '18 at 15:51











  • Better you create on demo in jsfiddle and shre with me. I will check and update you on same.

    – bimal sharma
    Nov 14 '18 at 6:50















0














you have to write self join query.



select te.name as leaderName,te1.name as childName from tbl_employee as te join tbl_employee as te1 on te.id = te1.leaders



this query gives you leader name with child name.






share|improve this answer























  • Yes, it's displaying but I am using CodeIgniter and data tables with child row. datatables.net/examples/api/row_details.html. I have to display like this.

    – user9437856
    Nov 13 '18 at 13:38











  • You have to include a JS library and add for loop to display table row

    – bimal sharma
    Nov 13 '18 at 15:31











  • There is no issue with JS. I already added. My scenario is different. Can you make jsfiddle for me for better understand?

    – user9437856
    Nov 13 '18 at 15:51











  • Better you create on demo in jsfiddle and shre with me. I will check and update you on same.

    – bimal sharma
    Nov 14 '18 at 6:50













0












0








0







you have to write self join query.



select te.name as leaderName,te1.name as childName from tbl_employee as te join tbl_employee as te1 on te.id = te1.leaders



this query gives you leader name with child name.






share|improve this answer













you have to write self join query.



select te.name as leaderName,te1.name as childName from tbl_employee as te join tbl_employee as te1 on te.id = te1.leaders



this query gives you leader name with child name.







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 13 '18 at 13:09









bimal sharmabimal sharma

565




565












  • Yes, it's displaying but I am using CodeIgniter and data tables with child row. datatables.net/examples/api/row_details.html. I have to display like this.

    – user9437856
    Nov 13 '18 at 13:38











  • You have to include a JS library and add for loop to display table row

    – bimal sharma
    Nov 13 '18 at 15:31











  • There is no issue with JS. I already added. My scenario is different. Can you make jsfiddle for me for better understand?

    – user9437856
    Nov 13 '18 at 15:51











  • Better you create on demo in jsfiddle and shre with me. I will check and update you on same.

    – bimal sharma
    Nov 14 '18 at 6:50

















  • Yes, it's displaying but I am using CodeIgniter and data tables with child row. datatables.net/examples/api/row_details.html. I have to display like this.

    – user9437856
    Nov 13 '18 at 13:38











  • You have to include a JS library and add for loop to display table row

    – bimal sharma
    Nov 13 '18 at 15:31











  • There is no issue with JS. I already added. My scenario is different. Can you make jsfiddle for me for better understand?

    – user9437856
    Nov 13 '18 at 15:51











  • Better you create on demo in jsfiddle and shre with me. I will check and update you on same.

    – bimal sharma
    Nov 14 '18 at 6:50
















Yes, it's displaying but I am using CodeIgniter and data tables with child row. datatables.net/examples/api/row_details.html. I have to display like this.

– user9437856
Nov 13 '18 at 13:38





Yes, it's displaying but I am using CodeIgniter and data tables with child row. datatables.net/examples/api/row_details.html. I have to display like this.

– user9437856
Nov 13 '18 at 13:38













You have to include a JS library and add for loop to display table row

– bimal sharma
Nov 13 '18 at 15:31





You have to include a JS library and add for loop to display table row

– bimal sharma
Nov 13 '18 at 15:31













There is no issue with JS. I already added. My scenario is different. Can you make jsfiddle for me for better understand?

– user9437856
Nov 13 '18 at 15:51





There is no issue with JS. I already added. My scenario is different. Can you make jsfiddle for me for better understand?

– user9437856
Nov 13 '18 at 15:51













Better you create on demo in jsfiddle and shre with me. I will check and update you on same.

– bimal sharma
Nov 14 '18 at 6:50





Better you create on demo in jsfiddle and shre with me. I will check and update you on same.

– bimal sharma
Nov 14 '18 at 6:50



















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53280772%2fhow-to-display-the-child-record-related-to-the-parent-record%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kleinkühnau

Makov (Slowakei)

Deutsches Schauspielhaus