Codeigniter set_template() создает два тега thead
Я использую codeigniter, чтобы помочь мне создать таблицу из базы данных mySQL, но set_template() создаст для меня два тега adad. Я не знаю, почему это происходит. И вот что я получил после того, как codeigniter создаст таблицу:
<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);
?>
Глядя на документацию таблицы CodeIgniter, heading_row_start
- это то, с чем начинается конкретный элемент. Это отличается от тегов open и close, которые вы определяете в этих элементах, что должно быть сделано как часть thead_open
и thead_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>',
- Вопросы
- Codeigniter
- Codeigniter set_template() создает два тега thead