如何在laravel5中以表格形式显示数据库数据

时间:2015-12-15 08:40:33

标签: laravel-5

我有对象形式的数据库表数据,比如这个

{"item_id": "1",
"item_color": "Black",
"item_size": "L",
"item_Quantity": "5",},

{"item_id": "2",
"item_color": "white",
"item_size": "M",
"item_Quantity": "5",},

{"item_id": "3",
"item_color": "green",
"item_size": "S",
"item_Quantity": "5",},

{"item_id": "4",
"item_color": "yellow",
"item_size": "S",
"item_Quantity": "5",}

我希望以表格格式显示数据。我正在搜索但我可以找到确切的解决方案。

1 个答案:

答案 0 :(得分:2)

有些事情:

<table>

    <thead>
        <tr>
            <td>Color:</td>
            <td>Size:</td>
            <td>Quantity:</td>
        </tr>
    </thead>

    <tbody>
        @foreach($items as $item)
            <tr>
                <td>$item->item_color</td>
                <td>$item->item_size</td>
                <td>$item->item_quantity</td>
            </tr>
        @endforeach
    </tbody>

</table>