0

我正在尝试使用 php 从 csv 文件中填充我的 Jquery Dtable 以解析 csv,然后尝试使用 Dtable 进行渲染,但似乎不起作用(

TypeError: nCell is undefined
[Break On This Error]   nCell.className += ' '+oCol.sClass; 

)。让它工作的其他解决方法是什么?

<script type="text/javascript" charset="utf-8">
            $(document).ready(function() {
                $('#result_table').dataTable();
            } );
</script>


<?php 
echo "
<table cellpadding='0' cellspacing='0' border='0' class='display' id='result_table' width='100%'>
            <thead>
                <th>Zeit</th>
                <th>Level</th>
                <th>Message</th>
                <th>Refferer</th>         
            </thead>\n\n";
$f = fopen("../logfile.csv", "r");
while (($line = fgetcsv($f)) !== false) {
        echo "<tr>";
        foreach ($line as $cell) {
                echo "<td>" . htmlspecialchars($cell) . "</td>";
        }
        echo "<tr>\n";
}
fclose($f);
echo "\n    <tfoot>
        <tr>
                <th>Zeit</th>
                <th>Level</th>
                <th>Message</th>
                <th>Refferer</th>     
        </tr>
    </tfoot></table>";
?>
4

1 回答 1

0

根据上面的评论,您似乎缺少标签。

<tbody>
</tbody>

在它读取 CSV 以确保它是一个有效的表之后,我会检查 Firebug 或 View Source 中的 HTML 输出。

于 2012-07-25T05:48:19.857 回答