2016-08-02 3 views
2

私はこのデータをprint_r()から持っています。ここで私は私のテーブルからfieldnameをである上記CodeIgniterを使用していた結果私のテーブルから1 coloumnが抜けています

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 
) 

です。次に、これを使って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%">No.</th><td width="20%"><?=$no;?></td>を削除した後、私は私が不足しているcoloumnを見ることができ、この部分に

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

を見ることができますよ。しかし、今私は行方不明second coloumn

私はそれをjsfiddleに入れました。そしてそれは正常に働いています(テーブルのみの場合)https://jsfiddle.net/kgokL5zw/

+0

を削除するようにしてください多分あなたは隠された第二のカラムを持って、あなたのDataTableの初期化コードを表示してください? –

+0

DataTable({"scrollX":true}); ' – YVS1102

+0

' thead'セクションで 'td'を使う点を除いてあなたのコードには問題はありません「th」の。 –

答えて

6

は、この部分に

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

foreachを閉じる前にインクリメントを$no++;に移動してください。

+0

同じ。 – YVS1102

+0

あなたのCSSまたはjsはそれを隠しているかもしれません...ちょうど別に$ arr [1]をエコーし​​ます... –

関連する問題