Limit number

2 posts by 2 authors in: Forums > CMS Builder
Last Post: October 6, 2010   (RSS)

Re: [s2smedia] Limit number

By Damon - October 6, 2010 - edited: October 6, 2010

Hi,

One way to limit the number of number of records to 4 is by adding a counter and an if statement:

<?php $counter = 1; ?>
<?php foreach ($service_listsRecords as $record): ?>
<?php if ($record['department'] != 'Interactive') { continue; } ?>
<?php if($counter <= 4) : ?>
<tr>
<td width="11%" align="left" valign="middle" style="padding:10px 10px 10px 10px"><img src="images/layout2_r4_c2.png" width="7" height="7" /></td>
<td width="89%" align="left" valign="middle"><a href="<?php echo $record['_link'] ?>"><?php echo $record['title'] ?></a></td>
</tr>
<?php endif; ?>
<?php $counter++; ?>

<?php endforeach ?>

Cheers,
Damon Edis - interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/