Current and Archive lists on the same page

4 posts by 2 authors in: Forums > CMS Builder
Last Post: July 25, 2013   (RSS)

I have got a Multi List that is going to display bulletins, I need it to display a current issue and then archived issues on the same page but in different lists, I have created 2 check boxes: Current and Archive, the table name is babington_bulletin, but I cannot get the 2 lists to display. Please can anyone help.

Ok, but how do I get the 2 lists to display separately, current in one area and archive in another, it seems I need to put a where statement or something on the actual page where the content displays.

By gregThomas - July 25, 2013

Hi, 

You would need to use two seperate foreach loops to pass through both arrays in the two locations where you want the records to display:

<div style="float:left">
  <!-- display records from first table -->
  <ul>
    <?php foreach($currentRecords as $record): ?>
      <li><?php echo $record['title']; ?></li>
    <?php endforeach; ?>
  </ul>
</div>
<div style="float:left">
  <!-- display records from second table -->
  <ul>
    <?php foreach($archiveRecords as $record): ?>
      <li><?php echo $record['title']; ?></li>
    <?php endforeach; ?>
  </ul>
</div>

This is just example code, so you'll need to modify it to work with your website.

So I've created two separate foreach loops to pass through the currentRecords and archiveRecord arrays separately. This way you can cycle through each loop where ever you want on your page.

Let me know if you have any questions.

Thanks!

Greg

Greg Thomas







PHP Programmer - interactivetools.com