【问题标题】:Display images in serverside datatable在服务器端数据表中显示图像
【发布时间】:2018-01-01 08:50:22
【问题描述】:

我有服务器端数据表,我正在尝试在 showimage 列中显示图像。 我尝试使用post 更改渲染列的代码,如下所示,但表格中没有显示图像:

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);
        }
    )
);

使用上面的代码,在src 图像路径不显示,结果图像不显示。 当通过源代码时显示为src="$d"

Mysql数据库:Mysql database 我已将图像放置在 .html 所在的两个位置和 images 文件夹中。

【问题讨论】:

标签: php jquery arrays datatables


【解决方案1】:

只需替换以下行:

return "<img class='zoom' src='$d' style='height:50px;width:50px;align:middle;'/>";

【讨论】:

  • 有趣。单引号与双引号确实有所作为。很高兴知道!谢谢。
猜你喜欢
  • 1970-01-01
  • 2013-03-06
  • 2019-09-30
  • 2016-06-22
  • 2021-12-11
  • 2016-08-31
  • 1970-01-01
  • 2016-02-25
  • 2021-10-11
相关资源
最近更新 更多