Ignore most current upload

7 posts by 2 authors in: Forums > CMS Builder
Last Post: September 5, 2014   (RSS)

By Mikey - September 4, 2014

I need to create a method to ignore and not display the most current record created in a multi-list, and only display 4 of the previously created multi-list records. So for example if "Record 12" is the most current, then records 11-7 will be displayed on the site, but record 12 would not. Once record 13 is created, then record 13 would not be displayed, but records 12-8 would be displayed.

Yea I know this sounds a bit strange, but it's what I need to accomplish.

Anyone have any suggestions on how to accomplish this?

Thanks Zick

By gregThomas - September 4, 2014

Hey Zicky, 

The simplest solution would be to not display the first record when you're looping through them:

<?php foreach($records as $key => $record): ?>
  <?php if($key == 0){ continue; } ?>

  //DISPLAY CONTENTS OF RECORDS HERE

<?php endforeach; ?>

So this code will loop through a list of items in an array (I'm assuming you're getting the records using the getRecords function). But if the item has a key of 0 (ie, it's the first in the list), it will not be displayed.

Cheers,

Greg

Greg Thomas







PHP Programmer - interactivetools.com

By Mikey - September 4, 2014

Hey Greg - thanks for the suggestion. Something happening, as it's removing all the records, not just the latest record. I've tried a few different configurations on your code and browsed the forum for tips that may help me get this figured out with no luck.

I am using the getRecords function.

By gregThomas - September 5, 2014

Hi Zicky,

Would it be possible to post/attach the code you've got so far so I can see what might be causing the issue?

Cheers,

Greg

Greg Thomas







PHP Programmer - interactivetools.com

By Mikey - September 5, 2014

Greg - can I email it to you instead?

By gregThomas - September 5, 2014

Sure thing, if you e-mail support@interactivetools.com I'll take a look for you.

Greg Thomas







PHP Programmer - interactivetools.com