How to combined the lastname firstname middlename in single datatable array column? - PHP
How to combined the lastname firstname middlename in single datatable array column? - PHP

I'm having trouble with my project. I can't figure out how I can combine these array
rows in a single array
column.
instead of
'lastname' => 1
'firstname' => 2
'middlename' => 3
to look like this
lastname, firstname - middlename => 1
server-side.php
// DB table to use
$table = 'patient_info';
// Table's primary key
$primaryKey = 'id';
// Array of database columns which should be read and sent back to DataTables.
// The `db` parameter represents the column name in the database, while the `dt`
// parameter represents the DataTables column identifier. In this case simple
// indexes
$columns = array(
array( 'db' => 'casenumber', 'dt' => 0 ),
array( 'db' => 'lastname', 'dt' => 1 ),
array( 'db' => 'firstname', 'dt' => 2),
array( 'db' => 'middlename', 'dt' => 3 ),
array('db' => 'birthday', 'dt' => 4, 'formatter' => function( $d, $row )
{
return date( 'M d, Y', strtotime($d));
}
),
array( 'db' => 'address', 'dt' => 5 )
);
// SQL server connection information
$sql_details = array(
'user' => 'root',
'pass' => '',
'db' => 'byh_records',
'host' => 'localhost'
);
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* If you just want to use the basic configuration for DataTables with PHP
* server-side, there is no need to edit below this line.
*/
require( 'ssp.class.php' );
echo json_encode(
SSP::simple( $_GET, $sql_details, $table, $primaryKey, $columns )
);
And can someone teach me what are the formatter types of this codes?
This discussion has been closed.
Answers
You need a column render function. The documentation is here
https://datatables.net/manual/data/renderers#Functions
and there are numerous explanations to be found in the forum.
I don't know what that means.