2015-09-10 22 views
0

我使用codeigniter來幫助我從mySQL數據庫創建表,但set_template()將爲我創建兩個thead標籤。我不知道爲什麼會發生這種情況。這裏是我得到了什麼之後笨創建表:Codeigniter set_template()創建兩個thead標籤

<table id = "guestList" style="border-collapse: collapse; width: 100%;"> 
<thead> 
<thead style="background: #E3EBEE; font-size: 15px;color: #1C75BC;"> 
<th style="padding: 10px;">Order#</th> 
<th style="padding: 10px;">Qty</th> 
<th style="padding: 10px;">Customer</th> 
<th style="padding: 10px;">Order Date</th> 
<th style="padding: 10px;">Ticket Type</th> 
<th style="padding: 10px;">Price</th> 
<th style="padding: 10px;">Delivery Method</th> 
<th style="padding: 10px;">Option</th> 
</thead> 
</thead> 

這是創建表的代碼:

<?php 
          $tmpl = array (
           'table_open'   => '<table id = "guestList" style="border-collapse: collapse; width: 100%;">', 

           'heading_row_start' => '<thead style="background: #E3EBEE; font-size: 15px;color: #1C75BC;">', 
           'heading_row_end'  => '</thead>', 
           'heading_cell_start' => '<th style="padding: 10px;">', 
           'heading_cell_end' => '</th>', 

           'row_start'   => '<tr>', 
           'row_end'    => '</tr>', 
           'cell_start'   => '<td style="padding: 10px;">', 
           'cell_end'   => '</td>', 

           'row_alt_start'  => '<tr>', 
           'row_alt_end'   => '</tr>', 
           'cell_alt_start'  => '<td style="padding: 10px;">', 
           'cell_alt_end'  => '</td>', 

           'table_close'   => '</table>' 
          ); 
          $this->table->set_template($tmpl); 
          $this->table->set_heading('Order#', 'Qty' , 'Customer', 'Order Date', 'Ticket Type', 'Price', 'Delivery Method'); 
          echo $this->table->generate($record); 
?> 
+0

Heading_row_start必須是。結束。 – Joerg

回答

0

望着CodeIgniter table documentation,該heading_row_start是具體項目的排什麼將開始。這與您在這些項目中定義的打開和關閉標籤不同,這應該作爲thead_openthead_close的一部分完成。

從文檔的例子如下:

$template = array(
     'table_open'   => '<table border="0" cellpadding="4" cellspacing="0">', 

     'thead_open'   => '<thead>', 
     'thead_close'   => '</thead>', 

     'heading_row_start'  => '<tr>', 
     'heading_row_end'  => '</tr>', 
     'heading_cell_start' => '<th>', 
     'heading_cell_end'  => '</th>', 

     'tbody_open'   => '<tbody>', 
     'tbody_close'   => '</tbody>', 

     'row_start'    => '<tr>', 
     'row_end'    => '</tr>', 
     'cell_start'   => '<td>', 
     'cell_end'    => '</td>', 

     'row_alt_start'   => '<tr>', 
     'row_alt_end'   => '</tr>', 
     'cell_alt_start'  => '<td>', 
     'cell_alt_end'   => '</td>', 

     'table_close'   => '</table>' 
); 

所以你需要更換你的

'heading_row_start' => '<thead style="background: #E3EBEE; font-size: 15px;color: #1C75BC;">', 
'heading_row_end'  => '</thead>', 

線:

'thead_open' => '<thead style="background: #E3EBEE; font-size: 15px;color: #1C75BC;">', 
'thead_close'  => '</thead>', 
+0

我有另一個問題。正如你所看到的,我有像「Qty」和「Price」這樣的列。是否有可能使用該模板來創建具有類名稱的整個表格單元格列?例如'''Qty'列 –