【问题标题】:How to make html table using foreach with fix first column?如何使用 foreach 制作 html 表格并修复第一列?
【发布时间】:2018-01-01 07:06:45
【问题描述】:
<table>

    <colgroup></colgroup>
    <colgroup></colgroup>
    <colgroup></colgroup>
    <colgroup></colgroup>

    <thead>
        <tr>
            <th>&nbsp;</th>
            @foreach($cloud as $cu)
            <th>
                <h2>{{$cu->name}}</h2><br>
                <h3 style="font-size: 35px;"><sup class="price-sign">$</sup>{{$cu->price}}<span style="font-size: large;">/{{trans('file.month')}}</span></h3>
                <p>{{$cu->description}}</p>
            </th>
            @endforeach
        </tr>
    </thead>

    <tfoot>

        <tr>
            <th>&nbsp;</th>
             @foreach($cloud as $cu)
            <td>
            <a href="/deatalis/{{$cu->id}}" style="text-decoration: none;" >More Details
            </a>



            </td>
            @endforeach
        </tr>

    </tfoot>

    <tbody>
        <tr>
            <th><i class="icon-user"></i>
            Members Number 
            <span>Cras mattis consectetur purus sit amet fermentum. Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor.</span>
            </th>
            @foreach($cloud as $cu)
            <td>{{$cu->users}}</td>
            @endforeach
        </tr>
        <tr>
            <th><i class="icon-drawer"></i>
            Storage 
            <span>Cras mattis consectetur purus sit amet fermentum. Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor.</span>
            </th>
            @foreach($cloud as $cu)
            <td>{{$cu->space}}</td>
            @endforeach
        </tr>
        <tr>
            <th><i class="icon-layers"></i>
            Backups 
            <span>Cras mattis consectetur purus sit amet fermentum. Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor.</span>
            </th>
            @foreach($cloud as $cu)
            <td>{{$cu->backup}}</td>
            @endforeach
        </tr>

    </tbody>

</table>

我想制作这张桌子: 在这种情况下,我为每一行制作 foreach 包括第一列标题加上同一行的每一列标题和每个表单的相同! 当我为所有表制作表单以发送参数时,这没有用!

所以我想固定第一列,然后用一个 foreach 来制作它 任何帮助! 谢谢

【问题讨论】:

    标签: php html laravel foreach html-table


    【解决方案1】:

    当您遍历数组或对象以生成动态表时,最好提前定义 theads(以静态方式)。

    【讨论】:

      猜你喜欢
      • 2018-12-16
      • 1970-01-01
      • 2017-09-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-03-16
      相关资源
      最近更新 更多