开发者

Symfony foreach show numbering

I have a form show a list of id and emails from database with the code below. I wonder if there anyway to include numbering in order instead of using the id.

<?php foreach($pager->getResults() as $user): ?>
  <tr>
    <td><?php echo $user->getId() ?></td>
    <td><?php echo $开发者_如何转开发user->getEmail() ?></td>
  </tr>
<?php endforeach; ?>

Method Using: Symfony form, Pagination.


I've never tested this code, but i think it should work

<?php $i = ($pager->getPage()-1)*$pager->getMaxPerPage()+1; ?>
<?php foreach($pager->getResults() as $user): ?>
  <tr>
    <td><?php echo $i ?></td>
    <td><?php echo $user->getEmail() ?></td>
  </tr>
<?php $i++; ?>
<?php endforeach; ?>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜