【问题标题】:Show fixed table with foreach function using PHP with codeigniter使用 PHP 和 codeigniter 显示带有 foreach 函数的固定表
【发布时间】:2019-04-22 14:11:55
【问题描述】:

我正在使用 CodeIgniter,我有表 which have fixed data on the left side,我必须使用 PHP 用数据库中的数据填充 1-12:

谁能帮助我了解如何从数据库中调用数据?

【问题讨论】:

  • 我认为您的问题是关于从数据库中获取数据。请问您的数据库结构。

标签: php mysql codeigniter foreach tabular


【解决方案1】:

这可能是解决方案:

CSS:

<style type="text/css">
.tg  {border-collapse:collapse;border-spacing:0;}
.tg td{font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;border-color:black;}
.tg th{font-family:Arial, sans-serif;font-size:14px;font-weight:normal;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;border-color:black;}
.tg .tg-xldj{border-color:inherit;text-align:left}
.tg .tg-0pky{border-color:inherit;text-align:left;vertical-align:top}
</style>

HTML 和 PHP:

<table class="tg">
    <tr>
        <th class="tg-xldj">Name</th>
        <th class="tg-0pky">Class</th>
        <th class="tg-0pky">Subject</th>
        <th class="tg-xldj">Date</th>
        <th class="tg-xldj">Score</th>
    </tr>
    <tr>
        <td class="tg-0pky">N1</td>
        <?php for($i=1;$i<=4;$i++) { ?>
            <td class="tg-0pky"><?=$i?></td>
        <?php } ?>
    </tr>
    <tr>
        <td class="tg-xldj">N2</td>
        <?php for($i=5;$i<=8;$i++) { ?>
            <td class="tg-0pky"><?=$i?></td>
        <?php } ?>
    </tr>
    <tr>
        <td class="tg-0pky">N3</td>
        <?php for($i=9;$i<=12;$i++) { ?>
            <td class="tg-0pky"><?=$i?></td>
        <?php } ?>
    </tr>
</table>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-07-06
    • 1970-01-01
    • 2016-08-16
    • 1970-01-01
    • 2016-12-09
    相关资源
    最近更新 更多