Need help to change ssp.class.php for datatable

Need help to change ssp.class.php for datatable

amirntmamirntm Posts: 10Questions: 3Answers: 1

Hi i using datatable with server-side option and i want to show custom value which is something different with value of database.

Thank you so much in advance.

This is my server side php-json code for datatable :

```
<?php
$table = 'datatables_demo';
$primaryKey = 'id';
$changer=0;
$columns = array(
array(
'db' => 'id',
'dt' => 'DT_RowId',
'formatter' => function( $d, $row ) {
return $changer++;
}
),
array( 'db' => 'first_name', 'dt' => 'first_name',
'formatter' => function( $d, $row ) {
return $changer++;
} ),
array( 'db' => 'last_name', 'dt' => 'last_name',
'formatter' => function( $d, $row ) {
return $changer++;
} )
);

$sql_details = array(
    'user' => '...',
    'pass' => '...',
    'db'   => '...',
    'host' => '...'
); // its just example and its ok (its connect to database correctly don't worry about database connection)

require( 'ssp.class.php' );

echo json_encode(
    SSP::simple( $_GET, $sql_details, $table, $primaryKey, $columns )
);
<?php > ``` ?>

As you can see there is a variable which is named $changer and it is 0 and in the code as you can see its going to plus 1 in each column of datatable like this $changer++ and also i using formatter on the script which is let me to show custom value except database value and also i can mix it with database value and also i want to mix it but its not work correctly yet the incorrect thing is it have to show this numbers as value in table on columns from first to last columns like this : 0,1,2 because changer was 0 and we put columns (DT_RowId) = $changer++ which is means 0 and after that (first_name) = $changer++ which is means 1 and then (last_name) = $changer++ which is mean 2 but it shows 2,2,2 like it was 2 from the first.
I don't want this i need 0,1,2 i mean not 0,1,2 it just shows the last thing which i set its not show what ever i set.

This discussion has been closed.