emp table branch table
A 1
B 1
C 1
D 2
E 2
F 2
G 3
H 3
我需要格式
下的数据表中的输出India
1 1 A
2 2 B
3 3 C
Singapore
4 1 D
5 2 E
php中的服务器处理代码
<?php
include_once("../../../../php/includes/dbconnection.php");
//SESSION START
session_start();
if (!isset($_SESSION['username'])) {
header("location:../../../index.php");
}
//MYSQL CONNECTION
$dbcon = GetDbcon();
$sql_details = GetDbconArray();
$table = 'vepl_employee';
$primaryKey = 'id';
$columns = array(
array('db' => 'D.branchName', 'dt' => '', 'field' => 'branchName'),
array('db' => 'A.engrCode', 'dt' => 1, 'field' => 'engrCode'),
array('db' => 'A.engrName', 'dt' => 2, 'field' => 'engrName',
'formatter' => function( $d, $row ) {
$tooltip = $d;
if (strlen($d) > 15)
$d = substr($d, 0, 15) . '...';
else
$d = $d;
return '<a title="'.$tooltip.'">'.$d.'</a>';
}
),
array('db' => 'D.branchName', 'dt' => 3, 'field' => 'branchName'),
array('db' => 'D.branchLocation', 'dt' => 4, 'field' => 'branchLocation'),
array('db' => 'A.internationalMobile', 'dt' => 5, 'field' => 'internationalMobile',
'formatter' => function( $d, $row ) {
$tooltip = $d;
if (strlen($d) > 15)
$d = substr($d, 0, 15) . '...';
else
$d = $d;
return '<a title="'.$tooltip.'">'.$d.'</a>';
}
),
array('db' => 'A.domesticMobile', 'dt' => 6, 'field' => 'domesticMobile',
'formatter' => function( $d, $row ) {
$tooltip = $d;
if (strlen($d) > 15)
$d = substr($d, 0, 15) . '...';
else
$d = $d;
return '<a title="'.$tooltip.'">'.$d.'</a>';
}
),
array('db' => 'B.project_place', 'dt' => 7, 'field' => 'project_place'),
array('db' => 'C.client_name', 'dt' => 8, 'field' => 'client_name',
'formatter' => function( $d, $row ) {
$tooltip = $d;
if (strlen($d) > 15)
$d = substr($d, 0, 15) . '...';
else
$d = $d;
return '<a title="'.$tooltip.'">'.$d.'</a>';
}
),
array('db' => 'A.employee_status', 'dt' => 9, 'field' => 'employee_status'),
array('db' => 'A.id', 'dt' => 10, 'field' => 'id')
);
require( 'ssp.class1.php' );
$joinQuery='FROM vepl_employee AS A LEFT JOIN vepl_project AS B ON B.id=A.currentProject LEFT JOIN vepl_client AS C ON C.id=B.client_id LEFT JOIN vepl_branches AS D ON D.id=A.branchId';
$where="A.engrDesignation NOT IN('Accounts Executive','Country Manager') AND A.employee_status != 'Deputed' AND A.currentProject != 0 AND A.company=".$_SESSION['company'];
$result = SSP::simple($_GET, $sql_details, $table, $primaryKey, $columns,$joinQuery,$where);
$start = $_REQUEST['start'];
$start++;
foreach ($result['data'] as &$res) {
$res[0] = (string) $start;
$start++;
}
echo json_encode(
$result
);
?>
在jquery函数中
$('#emptotTable').DataTable({
"processing": true,
"serverSide": true,
"ajax": "includes/employeelistServer.php",
"fnRowCallback": function (nRow, aData, iDisplayIndex) {
$('td:eq(1)', nRow).html('<a href="view_employee.php?id=' + aData[10] + '">' + aData[1] + '</a>');
return nRow;
},
"drawCallback": function () {
var api = this.api();
var rows = api.rows( {page:'current'} ).nodes();
var last=null;
api.column(4, {page:'current'} ).data().each( function ( group, i ) {
if ( last !== group ) {
$(rows).eq( i ).before(
'<tr class="group"><td colspan="10" style="color:#A21DF9;font-weight:bold;font-style: oblique;">'+group+'</td></tr>'
);
last = group;
}
} );
}
});
实际上我得到了那种格式的输出。但我需要输出上述格式。
India
1 A
2 B
3 C
Singapore
4 D
5 E
提前致谢