【问题标题】:Codeigniter: Adding an extra column in a default generated tableCodeigniter:在默认生成的表中添加额外的列
【发布时间】:2017-11-23 13:01:17
【问题描述】:

如何在生成的表格的左侧添加额外的列? 我真的不知道该怎么做。 提前致谢。

(我的代码的一个 sn-p)

$this->load->library('table');
        $this->table->set_caption($campagne);
        $this->table->set_heading('Campagne','Datum','Eindecode', 'Totaal',       '09:00', '09:30', '10:00', '10:30', '11:00', '11:30', '12:00', '12:30', '13:00', '13:30', '12:00', '12:30', '13:00', '13:30', '14:00', '14:30', '15:00', '15:30', '16:00', '16:30', '17:00', '17:30', '18:00', '18:30', '19:00', '19:30');
$template = array(
        'table_open'            => '<table border="1" 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>'
            );

    $this->table->set_template($template);     
    return $this->table->generate($query1);

抱歉,由于敏感信息,我无法向您展示所有内容

【问题讨论】:

  • 能否请您提供此脚本结果的屏幕截图?

标签: php sql-server codeigniter


【解决方案1】:

我认为您可以在左侧添加一个新列,包括 $query1 每一行中的第一个元素。例如,

for($i = 0; $i < count($query1); $i++){
  array_unshift($query1[$i], $element); 
}     
return $this->table->generate($query1);

其中 $element 应该是您在每种情况下想要的。 希望能帮到你! 谢谢。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-04-04
    • 1970-01-01
    • 1970-01-01
    • 2023-04-08
    • 2013-10-05
    • 1970-01-01
    • 2019-08-01
    • 2021-04-03
    相关资源
    最近更新 更多