Php 使用带有页码的序列号
我正在尝试使用变量Php 使用带有页码的序列号,php,laravel,laravel-5,Php,Laravel,Laravel 5,我正在尝试使用变量I检索刀片模板中的序列号: <?php $i=0;?> @foreach ($lists as $li) <tr><td><?php $i++;?>{{$i}}</td><td>{{$li->Name}}</td><td>{{$li->Telephone}} </td><td>{{$li->mobile}}&l
I
检索刀片模板中的序列号:
<?php $i=0;?>
@foreach ($lists as $li)
<tr><td><?php $i++;?>{{$i}}</td><td>{{$li->Name}}</td><td>{{$li->Telephone}}
</td><td>{{$li->mobile}}</td>
@endforeach
{!! $lists->render() !!}
因此,第一页的序列号是确定的。但是对于第二个页面,
i
再次从1开始。尝试将$i
设置为$lists->perPage()*($lists->currentPage()-1)
你也可以使用
@foreach($lists as $index => $list)
{{$index + $lists->firstItem()}} //S.N
@endforeach
$index
是该结果集中的行号,将获得分页结果中第一项的结果号。您需要将页面大小乘以$i
。这是我的意思。
$i = $lists->perPage() * ($lists->currentPage() - 1);
@foreach($lists as $index => $list)
{{$index + $lists->firstItem()}} //S.N
@endforeach