嗨,我尝试使用代码对请求数据列进行编码:
$serverName = "1.1.1.1";
$connectionInfo = array( "Database"=>"a", "UID"=>"a", "PWD"=>"a", 'CharacterSet' => 'a');
$conn = sqlsrv_connect( $serverName, $connectionInfo);
$requestData= $_REQUEST;
$columns = array(
0 => 'REGISTRATION_NUMBER',
1 => 'SEAFARER_CODE' ,
2 => 'LAST_NAME',
3 => 'FIRST_NAME',
4 => 'GENDER_ID',
5 => 'DOB',
6 => 'ENROLLMENT_LOCATION',
7 => 'ENROLLMENT_SCHEDULE',
8 => 'STATUS_ID',
9 => 'REASON_FOR_ISSUANCE'
);
$sql = "SELECT REGISTRATION_NUMBER, SEAFARER_CODE, LAST_NAME, FIRST_NAME, GENDER_ID, DOB, ENROLLMENT_LOCATION, ENROLLMENT_SCHEDULE , STATUS_ID, REASON_FOR_ISSUANCE from dbo.DEMOGRAPHICS";
$query=sqlsrv_query($conn, $sql, array(), array( "Scrollable" => 'static' )) or die("admin.php: get InventoryItems");
$totalData = sqlsrv_num_rows($query);
$totalFiltered = $totalData;
$sql = "SELECT REGISTRATION_NUMBER, SEAFARER_CODE, LAST_NAME, FIRST_NAME, GENDER_ID, DOB, ENROLLMENT_LOCATION, ENROLLMENT_SCHEDULE , STATUS_ID, REASON_FOR_ISSUANCE ";
$sql.=" from dbo.DEMOGRAPHICS WHERE 1 = 1";
if( !empty($requestData['columns'][8]['search']['value']) ){
$sql.=" AND STATUS_ID LIKE '".$requestData['columns'][8]['search'] ['value']."%' ";
}
$query=sqlsrv_query($conn, $sql, array(), array( "Scrollable" => 'static' )) or die("admin.php: get InventoryItems");
$totalFiltered = sqlsrv_num_rows($query);
$sql.=" ORDER BY ". $columns[$requestData['order'][0]['column']]." ".$requestData['order'][0]['dir']." LIMIT ".$requestData['start']." ,".$requestData['length']." ";
$query=sqlsrv_query($conn, $sql, array(), array( "Scrollable" => 'static' )) or die("admin.php: get InventoryItems");
$data = array();
while( $row=sqlsrv_fetch_array($query) ) {
$nestedData=array();
$nestedData[] = $row["REGISTRATION_NUMBER"];
$nestedData[] = $row["SEAFARER_CODE"];
$nestedData[] = 'a';
$nestedData[] = 'a';
$nestedData[] = 'a';
$nestedData[] = 'a';
$nestedData[] = 'a';
$nestedData[] = 'a';
$nestedData[] = 'a';
$nestedData[] = 'a';
$nestedData[] = 'a';
$data[] = $nestedData;
}
$json_data = array(
"draw" => intval( $requestData['draw'] ),
"recordsTotal" => intval( $totalData ),
"recordsFiltered" => intval( $totalFiltered ),
"data" => $data
);
echo json_encode($json_data);
?>
并显示错误:
注意:未定义索引:订购顺序 第39行的C:\ xampp \ htdocs \ sid \ services \ tabel \ admin.php
注意:未定义索引:在 第39行的C:\ xampp \ htdocs \ sid \ services \ tabel \ admin.php
注意:未定义索引:订购顺序 第39行的C:\ xampp \ htdocs \ sid \ services \ tabel \ admin.php
注意:未定义的索引:开始于 第39行的C:\ xampp \ htdocs \ sid \ services \ tabel \ admin.php
注意:未定义索引:长度为 第39行上的C:\ xampp \ htdocs \ sid \ services \ tabel \ admin.php admin.php:获取 库存物品