Check for last-record in list-viewer

2 posts by 2 authors in: Forums > CMS Builder
Last Post: January 23, 2009   (RSS)

Re: [virgodesign] Check for last-record in list-viewer

By Dave - January 23, 2009

Hi Avrom,

Try this:

<?php foreach ($sub_galleriesMenus as $record): ?>
<a href="#"><?php echo $record['gallery_name'] ?></a> &#8226;
<?php $isLastRecord = $record['num'] == $sub_galleriesMenus[-1]['num'] ?>
<?php if (!$isLastRecord): ?> &#8226; <?php endif ?>
<?php endforeach ?>


When you have an array (list) of records you can refer to them by number like this: $array[1], etc. Except it starts at zero. You can also refer to the last item in the list with -1. So this checks if the current record number being displayed has the same number as the last records number.

Let me know if that works for you.
Dave Edis - Senior Developer
interactivetools.com