How do I combine 2 MySql fields in one?
How do I combine 2 MySql fields in one?
JimBobUKII
Posts: 13Questions: 1Answers: 0
Hi,
I am using server-side script and was wondering how to combine to fields in one?. I put together the below and was looking to return both first and last name to a cell in datatables table. Is this how you would do it? If so it doesnt work for me? SOme users do not have a first or last name entered in the database
@allan you helped me before so adding you again
$columns = array(
array(
'db' => 'first_name',
'db' => 'last_name'
'dt' => 0 ),
'formatter' => function( $d, $row ) {
return $row['first_name'].' '.$row['last_name'];
}
),
array( 'db' => 'position', 'dt' => 2 ),
array( 'db' => 'office', 'dt' => 3 ),
array(
'db' => 'start_date',
'dt' => 4,
'formatter' => function( $d, $row ) {
return date( 'jS M y', strtotime($d));
}
),
array(
'db' => 'salary',
'dt' => 5,
'formatter' => function( $d, $row ) {
return '$'.number_format($d);
}
)
);
Answers
One client-side approach would be to send the data as it is, and merge cells on the client within
columns.render
, see this example here.Colin
@colin , I havent forgot!
Little busy at the moment, I will get back to you soon! Thanks for your reply