Limiting the first record, not record 1 but first record in drag sort order
2 posts by 2 authors in: Forums > CMS Builder
Last Post: March 31, 2014 (RSS)
Hi I am wondering if you can suggest a simple way to trim out the first record in a for each loop, I want to show all items except for the first one
By Chris - March 31, 2014
Hi Hybrid,
One way to accomplish this is by using a counter variable. If the counter indicates that the record is the first one, you can skip to the next record using continue. Add the lines in red to your foreach:
<?php $counter = 0; ?>
<?php foreach ($records as $record) ?>
<?php $counter = $counter + 1; ?>
<?php if ($counter === 1) { continue; } ?>
... display the record ...
<?php endforeach ?>
Does that help?
Chris