Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/290.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 数据表格式化数据输出_Php_Jquery_Datatables_Jquery Datatables - Fatal编程技术网

Php 数据表格式化数据输出

Php 数据表格式化数据输出,php,jquery,datatables,jquery-datatables,Php,Jquery,Datatables,Jquery Datatables,我正在使用带有服务器端处理的datatables,一切都很好,但我不知道如何在数据输出上使用php函数 我有这个密码 $('#exampless').dataTable({ "bProcessing": true, "bServerSide": true, "sAjaxSource": "data/load-anunciantes.php", "columnDefs": [ { "targets": -2, "data

我正在使用带有服务器端处理的datatables,一切都很好,但我不知道如何在数据输出上使用php函数

我有这个密码

$('#exampless').dataTable({

  "bProcessing": true,
    "bServerSide": true,

    "sAjaxSource": "data/load-anunciantes.php",     

     "columnDefs": [ {
        "targets": -2,
        "data": 7, // STATUS 1 or 0

    } ]



} );
第7列返回1或0很好,但我想这样做

关于php,我正在做什么

status($status);
如果状态=1,则返回激活状态

如果状态=0,则返回非活动状态


谢谢您的建议。

您需要使用
render
mRender
(取决于您使用的数据表版本):

“columnDefs”:[{
“渲染”:函数(数据、类型、行){
如果(第[7]行)=1){
返回“活动”;
}否则{
返回“不活动”;
}
},

谢谢,伙计,我正在使用我找到的解决方案,谢谢
"columnDefs": [ {
"render": function ( data, type, row ) {
    if(row[7] == 1){
        return '<label class=\'green\'>Active</label>';
    }else{
       return '<label class=\'red\'>Inactive</label>';
    }
 },