Invalid JSON shows when I try to join tables and show it to a datatable

Invalid JSON shows when I try to join tables and show it to a datatable

aikiiiaikiii Posts: 1Questions: 1Answers: 0

This shows up when I try to join tables, but when I query one table it shows normally What could be the problem? Can anyone hep me? I've spent days finding and trying the solutions I've seen but it's not working. Any help would be greatly appreciated!

This is my query that doesn't work
$sql = "SELECT tblEmpInfo.*, tblEmployee.* FROM tblEmpInfo JOIN tblEmployee ON tblEmpInfo.EmpID= tblEmployee.EmpID";
Here is my query that works

$sql = "SELECT * FROM tblEmpInfo";

This is my script

`

 $(document).ready(function() {
    $('#employeeTable').dataTable({
        "processing": true,
        "serverSide": false,
        "ajax": "/superadmin/employee/include-employee/fetch.php",
          "dom": 'lBfrtip',
           buttons: [
           {
               extend: 'pdf',
                className: 'btn btn-default btn-sm button',
               footer: true,
               exportOptions: {
                    columns: [0,1,2,3,4,5]
                }
           },
           {
               extend: 'csv',
                  className: 'btn btn-default btn-sm button',
               footer: false,
                exportOptions: {
                columns: [0,1,2,3,4,5]
                }
           },
           {
               extend: 'excel',
                  className: 'btn btn-default btn-sm button',
               footer: false,
                exportOptions: {
                columns: [0,1,2,3,4,5]
                }
           },
             {
               extend: 'print',
                  className: 'btn btn-default btn-sm button',
               footer: false,
                exportOptions: {
                columns: [0,1,2,3,4,5]
            }
           },   
              {
               extend: 'copy',
                  className: 'btn btn-default btn-sm button',
               footer: false,
                exportOptions: {
                columns: [0,1,2,3,4,5]
            }
           }       
        ] , 
        "rowId": 'EmpID',
        "columns": [
            {data: 'EmpID'},
            {data: 'FirstName'},
            // {data: 'Office'},
            // {data: 'Detachment'},
            // {data: 'Position'},
            // {data: 'Status'},
            {data: 'DateHired'},
            {data: 'Birthdate'},
            {data: 'Gender'},
            {data: 'CivStatus'},
            {data: 'Nationality'}, 
            {data: 'EmpID'},
        ],
        'columnDefs': [ {
        'targets': [6], 
        'orderable': false, 
         "render": function (data, type, row, meta) {
         return '<a class="btn btn-primary btn-sm edit" href="employees.php/view/' + data + '"> Edit </a>';
       }
     }],
     "oLanguage": {
                    "sSearch": " "
                },

    });
}); 

`

I tried adding , name: 'tblEmpInfo.EmpID' and such on every column but it's not working...

Answers

Sign In or Register to comment.