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; ?>
精彩评论