Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/257.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
DataTable插件无法使用动态生成的php表(箭头不会显示)_Php_Jquery_Jquery Plugins_Datatables - Fatal编程技术网

DataTable插件无法使用动态生成的php表(箭头不会显示)

DataTable插件无法使用动态生成的php表(箭头不会显示),php,jquery,jquery-plugins,datatables,Php,Jquery,Jquery Plugins,Datatables,我使用php创建了一个表,并添加了插件(使用demo_table.css)。箭头不会显示在结果页面上,并且不会显示;不要应用任何css 以下是我的php代码: $result = mysqli_query($link, $sql); $num_rows = mysqli_num_rows($result); echo '<table cellpadding = "0" cellspacing="0" border="0" id="datatables"

我使用php创建了一个表,并添加了插件(使用demo_table.css)。箭头不会显示在结果页面上,并且不会显示;不要应用任何css

以下是我的php代码:

        $result = mysqli_query($link, $sql);

$num_rows = mysqli_num_rows($result);
        echo '<table cellpadding = "0" cellspacing="0" border="0" id="datatables"  class="display">';
        echo '<thead>';
        echo '<tr>';
        echo '<th>SNo.</th>
        <th>Username</th>
        <th>Trip ID</th>
        <th>Destination</th>
        <th >Leave Date</th>
        <th>Return Date</th>
        <th>Total</th>
        <th>Submit Date</th>
        <th >Status</th>
        <th >Reason</th>
        <th >Update</th>';
        echo '</tr>';
        echo '</thead>';
        echo '<tbody>';

}       else {
            echo('not valid user');
        }

if (!$result) {
    die(mysqli_error($link));

    }

if ($num_rows<=0){
    echo('not valid user');
    }

    elseif ($num_rows>0){
        $i=1;
        while($row = mysqli_fetch_assoc($result)) {

                $grandtotal = $row['flight_estimate'] + $row['registration_fee'] + $row['total_cost'];
                $status = $row['status'];
                if(($status == 'Approved') || ($status == 'Denied')){
                    $newcolumn = '<td></td>';
                }
                else{
                    $newcolumn = '<td><a href="Adminview.php?trip_id=' . $row['trip_id'] . '" id="editlink">Approve/Deny</a></td>';

                }

                echo '<tr>';
                echo '<td>'. $i++ .'</td><td>'.$row['username'].'</td><td>'.$row['trip_id'].'</td><td>'.$row['destination'].'</td><td>'.date('d/m/Y',strtotime($row['leave_date'])).'</td><td >'.date('d/m/Y',strtotime($row['return_date'])).'</td><td >'. round($grandtotal,2).'</td><td >'.date('d/m/Y',strtotime($row['updateddate'])).'</td><td >'.$row['status'].'</td><td >'.$row['reason'].'</td>'.$newcolumn;
            }
    echo '</tr>';
    echo '</tbody>';
    echo '</table>';
$result=mysqli\u查询($link,$sql);
$num_rows=mysqli_num_rows($result);
回声';
回声';
回声';
埃科·斯诺。
用户名
行程ID
目的地
休假日期
返回日期
全部的
提交日期
地位
理由
更新';
回声';
回声';
回声';
}否则{
echo(‘无效用户’);
}
如果(!$result){
die(mysqli_错误($link));
}
如果($num_rows0){
$i=1;
while($row=mysqli\u fetch\u assoc($result)){
$grandtotal=$row['flight_estimate']+$row['registration_fee']+$row['total_cost'];
$status=$row['status'];
如果($status=='Approved')| |($status=='Denied')){
$newcolumn='';
}
否则{
$newcolumn='';
}
回声';
回显'.$i++.'.$row['username'].'.$row['trip'U id'.].'.$row['destination'.].'.date('d/m/Y',STROTIME('row['leave'U date'])。'.date('d/m/Y',STROTIME('return date'])。'round('return日期['return date'])。.round('grandtotal,2.)。'.date('d/m/m/Y',STROTIME('row['UpdateDate'])。$row['UpdateDate')。$row['status'])。$row['NewReason';
}
回声';
回声';
回声';
} ?>


有什么我遗漏的吗?它所做的只是将所有列值居中。但当我单击标题时,什么也不会发生。

在初始化dataTable时,需要将“bJQueryUI”设置为true

$("#datatables").dataTable({ 'bJQueryUI' : true });

如果您发布了js脚本,这会有所帮助,因为这就是您的问题所在。

我会先清理一下所有这些条件,您可能不需要全部。现在,elseif有了空间,你写的没有空间。else if()。在哪里初始化数据表?@davidkonrad我的主页中有一个单独的脚本文件。。这是它的一部分:$(document).ready(function(){$(“#数据表”).datatable()});