pagination start and length not working
pagination start and length not working
As shown above, the page length does not increasing each time i move to a new page.
And im using server side processing with php oci, everything works fine unless the page length still getting error. please help
this is the fetchdata.php
```
<?php
session_start();
$username = "OPS_ADMIN";
$password = "BULET2KALI";
// Create connection to Oracle
ini_set ("display_errors", "0");
error_reporting(E_ALL);
$conn = oci_connect($username, $password, '(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 103.121.213.170)(PORT = 1521)) (CONNECT_DATA = (SERVICE_NAME = BUMHO) (SID = BUMHO)))');
if (!$conn) {
$m = oci_error();
echo $m['message'], "\n";
oci_free_statement($stid);
oci_close($conn);
exit;
}
$requestData = $columns = $totalRecords = $data = array();
// $requestData= $_REQUEST;
$columns = array(
0 =>'TANGGALAN',
1 => 'EMPNAME',
2 => 'TGJWB_AFD',
3 => 'BLOCKCODE',
4 => 'TPHCODE',
5 => 'SEKSIDESC',
6 => 'HEKTAR',
7 => 'POKOKNYA',
8 => 'TONASE',
9 => 'BJR',
10 => 'JJG_PANEN',
11 => 'REALKGPANEN',
12 => 'REALKGBROD',
13 => 'VARIANCE',
14 => 'VARIANCEPERCENT',
15 => 'BUTIR_BRD',
16 => 'PRUNNINGSONGGO'
);
$sql = "SELECT COUNT(*) AS C FROM EPMS_TRXI.t_variance_bkpops BK LEFT JOIN T_VA_USERAFD UA ON BK.DIVISIONCODE = UA.TGJWB_AFD WHERE UA.USERNAME = 'EKA SYAHPUTRA'";
$query=oci_parse($conn, $sql);
oci_execute($query);
oci_fetch_all($query, $result);
$numrows = $result['C'][0];
$totalFiltered = $numrows;
$vaquery = "SELECT COUNT(*) AS C FROM EPMS_TRXI.t_variance_bkpops BK LEFT JOIN T_VA_USERAFD UA ON BK.DIVISIONCODE = UA.TGJWB_AFD WHERE UA.USERNAME = 'EKA SYAHPUTRA'";
if(isset($_POST['search']['value'])) {
//----------------------------------------------------------------------------------
$vaquery = $vaquery . " AND ( BK.TPHCODE LIKE '".$_POST['search']['value']."%' ";
$vaquery = $vaquery . " OR BK.BLOCKCODE LIKE '".$_POST['search']['value']."%' ";
$vaquery = $vaquery . " OR BK.EMPNAME LIKE '".$_POST['search']['value']."%' ";
$vaquery = $vaquery . " OR BK.SEKSIDESC LIKE '".$_POST['search']['value']."%' ";
$vaquery = $vaquery . " OR UA.TGJWB_AFD LIKE '".$_POST['search']['value']."%' ) ";
}
$vatablenum = oci_parse($conn, $vaquery);
oci_execute($vatablenum);
oci_fetch_all($vatablenum, $res);
$numfiltered = $res['C'][0];
$totalFiltered = $numfiltered;
//----------------------------------------------------------------------------------
$vadynamicsql = "SELECT *
FROM ( SELECT a.*, ROWNUM AS RNUM
FROM (SELECT TO_CHAR(BK.WORKING_DATE, 'DD/MM/YYYY') AS TANGGALAN, BK.EMPNAME, UA.TGJWB_AFD, BK.BLOCKCODE, BK.TPHCODE, BK.SEKSIDESC, CAST(BK.HA_PROD AS DECIMAL(10,2)) AS HEKTAR,
CAST(BK.POKOK_PROD AS DECIMAL(10,3)) AS POKOKNYA, CAST(BK.TONASE_PROD AS DECIMAL(10,3)) AS TONASE, CAST(BK.BJR_PROD AS DECIMAL(10,2)) AS BJR, BK.JJG_PANEN,
CAST(BK.KG_PANEN AS DECIMAL(10,3)) AS REALKGPANEN, CAST(BK.KG_BRD AS DECIMAL(10,3)) AS REALKGBROD, CAST(BK.KG_PANEN - BK.TONASE_PROD AS DECIMAL(10,2)) AS VARIANCE,
CAST((BK.KG_PANEN / BK.TONASE_PROD)*100 AS DECIMAL(10,2)) AS VARIANCEPERCENT, BK.BUTIR_BRD, BK.PRUNNINGSONGGO FROM EPMS_TRXI.t_variance_bkpops BK
LEFT JOIN T_VA_USERAFD UA ON BK.DIVISIONCODE = UA.TGJWB_AFD WHERE UA.USERNAME = 'EKA SYAHPUTRA'";
if(isset($_POST['search']['value'])) {
//----------------------------------------------------------------------------------
$vadynamicsql = $vadynamicsql . " AND ( BK.TPHCODE LIKE '".$_POST['search']['value']."%' ";
$vadynamicsql = $vadynamicsql . " OR BK.BLOCKCODE LIKE '".$_POST['search']['value']."%' ";
$vadynamicsql = $vadynamicsql . " OR BK.EMPNAME LIKE '".$_POST['search']['value']."%' ";
$vadynamicsql = $vadynamicsql . " OR BK.SEKSIDESC LIKE '".$_POST['search']['value']."%' ";
$vadynamicsql = $vadynamicsql . " OR UA.TGJWB_AFD LIKE '".$_POST['search']['value']."%' ) ";
}
$vadynamicsql = $vadynamicsql . " ORDER BY ".$columns[$_POST['order'][0]['column']]." ".$_POST['order'][0]['dir'].") ";
$vadynamicsql = $vadynamicsql . " a WHERE ROWNUM <= ".$_POST['length']." ) WHERE RNUM >= ".$_POST['start']." ";
$vatable = oci_parse($conn, $vadynamicsql);
oci_execute($vatable);
$data = array();
while ($row = oci_fetch_array($vatable, OCI_BOTH)) {
$nestedData=array();
$nestedData[] = $row['TANGGALAN'];
$nestedData[] = $row['EMPNAME'];
$nestedData[] = $row['TGJWB_AFD'];
$nestedData[] = $row['BLOCKCODE'];
$nestedData[] = $row['TPHCODE'];
$nestedData[] = $row['SEKSIDESC'];
$nestedData[] = $row['HEKTAR'];
$nestedData[] = $row['POKOKNYA'];
$nestedData[] = $row['TONASE'];
$nestedData[] = $row['BJR'];
$nestedData[] = $row['JJG_PANEN'];
$nestedData[] = $row['REALKGPANEN'];
$nestedData[] = $row['REALKGBROD'];
$nestedData[] = $row['VARIANCE'];
$nestedData[] = $row['VARIANCEPERCENT'];
$nestedData[] = $row['BUTIR_BRD'];
$nestedData[] = $row['PRUNNINGSONGGO'];
$data[] = $nestedData;
}
$json_data = array(
"draw" => intval( $_POST['draw'] ),
"recordsTotal" => intval( $numrows ),
"recordsFiltered" => intval( $totalFiltered ),
"data" => $data );
//----------------------------------------------------------------------------------
echo json_encode($json_data);
Edited by Colin - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.
This question has an accepted answers - jump to answer
Answers
im using post method.
Sorry for the bad formatted question, this is my first time asking a question here.
The page length parameter that DataTables sends is:
So if your display page size is 10, DataTables will always send 10 for this parameter. It sounds like you were expecting it to go up to the index of the last record to be displayed, e.g. 10, 20, 30...? If so, then add the start to the length.
Allan