Laravel 4.2 分页自动递增行号
Laravel 4.2 auto incrementing row number with pagination
我每页有 15 行。我想在分页时增加行数。
***** 我用 Laravel 4.2 *****
<div class="portlet-body">
<div class="table-responsive">
<table class="table table-hover">
<thead>
<tr>
<th class="col-md-1">no</th>
<th class="col-md-2">name</th>
</tr>
</thead>
<tbody>
<?php
$i = 1;
$count = Permit::count();
$stat = Config::get('permit.status');
$color = Config::get('permit.color');
?>
@foreach ($list as $lst)
<tr>
<td>{{ $i++ }}</td>
<td>{{ HTML::linkRoute('dashboard.admin.permit.show',$lst->name, array($lst->id)) }}</td>
</tr>
@endforeach
<?php echo $list->appends(Input::except('page'))->links(); ?>
</tbody>
</table>
</div>
</div>
但是当我转到下一页时,$count 变量从头开始。我怎样才能得到 $i = 16 并且它会递增等等?
只获取页数和每页的结果
$i = $i+ ((number_of_page-1) * perpage)
我每页有 15 行。我想在分页时增加行数。
***** 我用 Laravel 4.2 *****
<div class="portlet-body">
<div class="table-responsive">
<table class="table table-hover">
<thead>
<tr>
<th class="col-md-1">no</th>
<th class="col-md-2">name</th>
</tr>
</thead>
<tbody>
<?php
$i = 1;
$count = Permit::count();
$stat = Config::get('permit.status');
$color = Config::get('permit.color');
?>
@foreach ($list as $lst)
<tr>
<td>{{ $i++ }}</td>
<td>{{ HTML::linkRoute('dashboard.admin.permit.show',$lst->name, array($lst->id)) }}</td>
</tr>
@endforeach
<?php echo $list->appends(Input::except('page'))->links(); ?>
</tbody>
</table>
</div>
</div>
但是当我转到下一页时,$count 变量从头开始。我怎样才能得到 $i = 16 并且它会递增等等?
只获取页数和每页的结果
$i = $i+ ((number_of_page-1) * perpage)