php - 我的表 sql 中缺少一列

标签 php jquery html codeigniter datatables

我有来自 print_r() 的数据。这是结果

Array
(
    [0] => Customer
    [1] => 01/08/2016
    [2] => 02/08/2016
    [3] => 03/08/2016
    [4] => 04/08/2016
    [5] => 05/08/2016
    [6] => 06/08/2016
    [7] => 07/08/2016
    [8] => 08/08/2016
    [9] => 09/08/2016
    [10] => 10/08/2016
    [11] => 11/08/2016
    [12] => 12/08/2016
    [13] => 13/08/2016
    [14] => 14/08/2016
    [15] => 15/08/2016
    [16] => 16/08/2016
    [17] => 17/08/2016
    [18] => 18/08/2016
    [19] => 19/08/2016
    [20] => 20/08/2016
    [21] => 21/08/2016
    [22] => 22/08/2016
    [23] => 23/08/2016
    [24] => 24/08/2016
    [25] => 25/08/2016
    [26] => 26/08/2016
    [27] => 27/08/2016
    [28] => 28/08/2016
    [29] => 29/08/2016
    [30] => 30/08/2016
    [31] => 31/08/2016
)

我正在使用CodeIgniter上面是fieldname从我的 table 上。然后我将用它创建 HTML 表

<style>
table th:nth-child(3), td:nth-child(3) {
  display: none;
}

    .cstm{
        padding-top:25px;
        background-color:white;
    }
</style>

<table id="tbl" class="table table-bordered table-striped">
    <thead>
        <tr align="center">
            <th width="20%">No.</th>
            <?php foreach($fields as $header) { ?><th width="20%"><?=$header;?></th><?php } ?> //The array from above...
        </tr>
    </thead>
    <tbody>
        <?php 
            $no = 0;
            if($hasil != ""){
                foreach($hasil as $hsl)
                    {$no++;
        ?>
        <tr> 
            <td width="20%"><?=$no;?></td>
            <?php foreach($fields as $header => $key) { ?>
                <td data-original-title="<?=currency($hsl->Customer);?> - <?=currency($hsl->$key);?>" data-container="body" data-toggle="tooltip" data-placement="bottom" title="" class= 'ygdiganti' <?php if($hsl->$key == "") {echo "bgcolor='#FF0000'";} ?> width="20%"><?=currency($hsl->$key);?></td>
            <?php } ?>
        </tr>
        <?php
            }
                }?>
    </tbody>    
</table>   

我可以使用我的脚本创建表。但我缺少这部分[1] => 01/08/2016

结果示例:

Customer    01/07/2016  02/07/2016  03/07/2016  04/07/2016  05/07/2016  06/07/2016  07/07/2016  08/07/2016  09/07/2016  10/07/2016  11/07/2016  12/07/2016  13/07/2016  14/07/2016  15/07/2016  16/07/2016  17/07/2016  18/07/2016  19/07/2016  20/07/2016  21/07/2016  22/07/2016  23/07/2016  24/07/2016  25/07/2016  26/07/2016  27/07/2016  28/07/2016  29/07/2016  30/07/2016  31/07/2016
K-LFATR 9826550 23215880    17859700    13272850    NULL    2108900 7356570 NULL    NULL    NULL    NULL    5547920 NULL    NULL    NULL    NULL    9550809 NULL    NULL    NULL    7479130 9869629 NULL    NULL    NULL    NULL    NULL    NULL    NULL    NULL    NULL

这是屏幕截图 enter image description here

你们能告诉我为什么吗[1] => 01/08/2016失踪了?

好的。在我通过浏览器检查源之后ctrl+u 。我能够看到这部分

<th width="20%">Customer</th>
<th width="20%">01/08/2016</th>
<th width="20%">02/08/2016</th>

删除<th width="20%">No.</th>后和<td width="20%"><?=$no;?></td>我可以看到丢失的列。但现在我错过了 second coloumn

我已经把它放在jsfiddle里了。它工作正常(如果只有表)https://jsfiddle.net/kgokL5zw/

最佳答案

尝试删除这部分

table th:nth-child(3), td:nth-child(3) {
  display: none;
}

关于php - 我的表 sql 中缺少一列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38710960/

相关文章:

javascript - 如何在javascript中增加函数值?

php - 使用 PHP 的四个最新图像 2x2

php - 如何在 PHP 中使用递归计算阶乘

php - 如何在Linux中从命令行生成xls文件?

jQuery、.empty() 和内存

javascript - AngularJS 应用程序的引导/初始化流程

Javascript/jQuery 在单击时更改 CSS 不起作用

javascript - 如何触发 javascript css 操作?

php - PHP 中的异或字符串与 key

jquery - 如何使用 jquery 将数据从 django View 动态加载到 django 模板而不刷新页面?