如何在 Laravel 5.2 中增加 Semantic-UI Table 的计数
How to increment count for Semantic-UI Table in Laravel 5.2
这可能是个菜鸟问题,但我还没有在网上找到任何关于如何做到这一点的信息。
我有一个 table 显示最高分的排行榜。
这是它的样子:
我需要计算每行有用户名的次数,所以如果 table 中有 23 条记录,那么我需要在 # 所在的左侧显示 1-23。
我试过用这个:
@for ($i = 0; $i < 10; $i++)
{{ $i }}
@endfor
在我的 table:
<table class="ui celled striped selectable inverted table">
<thead>
<tr>
<th colspan="3" class="center aligned">
Leaderboards
</th>
</tr>
<tr>
<th>#</th>
<th class="center aligned">Username</th>
<th class="center aligned"><i class="fa fa-diamond"></i> Points</th>
</tr>
</thead>
<tbody>
@foreach ($points as $point)
<tr>
<td>
#
</td>
<td class="center aligned"> {{ $point->username }}</td>
<td class="center aligned"><i class="fa fa-diamond"></i> {{ $point->points }}</td>
</tr>
@endforeach
</tbody>
</table>
但我一直在一行中从 1-10 循环
初始化一个计数器变量 $i
并在循环结束时递增它,如下所示:
<table class="ui celled striped selectable inverted table">
<thead>
<tr>
<th colspan="3" class="center aligned">
Leaderboards
</th>
</tr>
<tr>
<th>#</th>
<th class="center aligned">Username</th>
<th class="center aligned"><i class="fa fa-diamond"></i> Points</th>
</tr>
</thead>
<tbody>
<?php $i = 0; ?>
@foreach ($points as $point)
<tr>
<td>
# {{ $i }}
</td>
<td class="center aligned"> {{ $point->username }}</td>
<td class="center aligned"><i class="fa fa-diamond"></i> {{ $point->points }}</td>
</tr>
<?php $i++; ?>
@endforeach
</tbody>
</table>
这可能是个菜鸟问题,但我还没有在网上找到任何关于如何做到这一点的信息。
我有一个 table 显示最高分的排行榜。
这是它的样子:
我需要计算每行有用户名的次数,所以如果 table 中有 23 条记录,那么我需要在 # 所在的左侧显示 1-23。
我试过用这个:
@for ($i = 0; $i < 10; $i++)
{{ $i }}
@endfor
在我的 table:
<table class="ui celled striped selectable inverted table">
<thead>
<tr>
<th colspan="3" class="center aligned">
Leaderboards
</th>
</tr>
<tr>
<th>#</th>
<th class="center aligned">Username</th>
<th class="center aligned"><i class="fa fa-diamond"></i> Points</th>
</tr>
</thead>
<tbody>
@foreach ($points as $point)
<tr>
<td>
#
</td>
<td class="center aligned"> {{ $point->username }}</td>
<td class="center aligned"><i class="fa fa-diamond"></i> {{ $point->points }}</td>
</tr>
@endforeach
</tbody>
</table>
但我一直在一行中从 1-10 循环
初始化一个计数器变量 $i
并在循环结束时递增它,如下所示:
<table class="ui celled striped selectable inverted table">
<thead>
<tr>
<th colspan="3" class="center aligned">
Leaderboards
</th>
</tr>
<tr>
<th>#</th>
<th class="center aligned">Username</th>
<th class="center aligned"><i class="fa fa-diamond"></i> Points</th>
</tr>
</thead>
<tbody>
<?php $i = 0; ?>
@foreach ($points as $point)
<tr>
<td>
# {{ $i }}
</td>
<td class="center aligned"> {{ $point->username }}</td>
<td class="center aligned"><i class="fa fa-diamond"></i> {{ $point->points }}</td>
</tr>
<?php $i++; ?>
@endforeach
</tbody>
</table>