0

I have server-side datatable in which I'm trying to show images in showimage column. I tried to change code for rendering column using this post which is as below but no images are displayed in table:

Server_processing.php:

$columns = array(
    array( 'db' => 'first_name', 'dt' => 0 ),
    array( 'db' => 'last_name',  'dt' => 1 ),
    array( 'db' => 'position',   'dt' => 2 ),
    array( 'db' => 'office',     'dt' => 3 ),
    array( 
        'db' => 'showimage',
        'dt' => 4,
        'formatter' => function( $d, $row ) {
            return '<img src="$d" style="height:50px;width:50px;"/>';
        }       
        ),  
    array(
        'db'        => 'salary',
        'dt'        => 6,
        'formatter' => function( $d, $row ) {
            return '$'.number_format($d);
        }
    )
);

With above code, in src image path is not displayed as a result image is not displayed. It is showing when go thru source code as src="$d"

Mysql database: Mysql database I have placed images at both places where .html resides and in images folder.

SSG
  • 73
  • 1
  • 10
  • @Aniket Sahrawat, Thanks, I am new to all this, can you please help me. – SSG Jan 01 '18 at 09:01
  • I am not getting you, here is the datatable i am using: https://datatables.net/examples/data_sources/server_side.html – SSG Jan 01 '18 at 09:10

1 Answers1

1

Just replace below line:

return "<img class='zoom' src='$d' style='height:50px;width:50px;align:middle;'/>";
Samadhan Gaikwad
  • 186
  • 4
  • 21
  • Interesting. The single quote vs double quote really did make a difference. Good to know! Thanks. –  Jan 11 '19 at 06:32