How do i Output Two columns from mysql to one data cell
How do i Output Two columns from mysql to one data cell
dannjoroge
Posts: 6Questions: 4Answers: 0
Hi am trying to output two columns from a mysql database to one cell in the datatable. how do i do that am using the server side array in php
__$columns = array(
array( 'db' => 'no', 'dt' => '0' ),
array( 'db' => 'name', 'dt' => '1' ),
array( 'db' => 'phoneno', 'dt' => '2' ),
array( 'db' => 'email', 'dt' => '3' ),
array(
'db' => 'idno',
'dt' => '4',
),
array(
'db' => 'idno',
'dt' => '5',
),
array( 'db' => 'clientno', 'dt' => '6', 'formatter' => function( $d, $row ) {
return '<a href="../clients/add_clients.php?clientid='.$row[6].'"><span class="label label-inverse"><i class="fa fa-edit"></i> Edit</span></a>';},
'field' => 'clientno' )
);__
This discussion has been closed.
Answers
You can use the render function to decorate the columns.
Here I am populating datatable #table with three columns. col1, col2 and "New Column"
New Column is merged using col3 and col4
Hope this may help.
In addition to @nava1021's excellent answer, you might also find the rendering manual page to be useful.
Allan
thanks i used a server side script using php works like a charm