Laravel 4.2使用分页自动递增行号

时间:2018-05-02 12:55:23

标签: php pagination laravel-4.2

每页有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 var从头开始。如何获得$ i = 16并且它会增加等等?

1 个答案:

答案 0 :(得分:0)

只获取页数和每页结果

$i = $i+ ((number_of_page-1) * perpage)
相关问题