开发者

Codeigniter2 - Generate a table that contain multiple sub-table

For the Table class in user guide, it mention how to generate a table with multiple columns/rows. But I want to ask how can we generate a table that contain multiple sub-table, example as below:

<table>
    <tr>
        <td>
            <table>
                <tr>
                    <td>sub-table-01</td>
                </tr>
            </table>
        </td>
        &开发者_JS百科lt;td>
            <table>
                <tr>
                    <td>sub-table-02</td>
                </tr>
            </table>
        </td>
        <td>
            <table>
                <tr>
                    <td>sub-table-n</td>
                </tr>
            </table>
        </td>
    </tr>
</table>

Could anyone suggest the snippet for this function?

Thanks


You can nest the calls to generate(). Example:

$data1 = array(
    array(1, 2, 3),
    array(4, 5, 6),
    array(7, 8, 9),
);
$data2 = array(
    array('a', 'b'),
    array('c', 'd'),
    array('e', 'f'),
);
$data3 = array(
    array('Heading1', 'Heading 2', 'Heading 3'),
    array('Row1', $this->table->generate($data1), $this->table->generate($data2)),
    array('Row2', $this->table->generate($data1), $this->table->generate($data2)),
    array('Row3', $this->table->generate($data1), $this->table->generate($data2)),
);
echo $this->table->generate($data3);

You'll have to replace this with your own data in a way that makes sense of course, but hopefully this gives you the idea.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜