Display Certain Records

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

So i have a bunch of records with check boxes, either "Participating Bar" or "Not Participating Bar". How do I show only the records that have the "Participating Bar" checked?

Thanks!

Re: [greg] Display Certain Records

What if I wanted the Participating Bars to be clickable links to their detail page, and the Not Participating Bars to show below the Participating Bars list which will be just a list, not links...

Re: [shawnpatoka] Display Certain Records

To keep things simple I would make two getRecords requests, one for bars who are participating and one for any which aren't, then loop through both of them individually.

Something like this should work:

<?php

list($participating, $barMetaData) = getRecords(array(
'tableName' => 'barSection',
'loadUploads' => true,
'allowSearch' => false,
'where' => "participatingBarField = '1'"
));

list($notParticipating, $barMetaData) = getRecords(array(
'tableName' => 'barSection',
'loadUploads' => true,
'allowSearch' => false,
'where' => "participatingBarField = '0'"
));
?>


<?php foreach($participating as $row): ?>
<p><?php echo $row['title']; ?></p>
<a href="detailsPage.php?num=<?php echo $row['num'];?>" ><?php echo $row['title']; ?></a>
<?php endforeach; ?>

<?php foreach($notParticipating as $row): ?>
<p><?php echo $row['title']; ?></p>
<?php endforeach; ?>


You'll need to change fields, file names and sections so that they are applicable to your example.

Let me know if this doesn't work.

Thanks
Greg Thomas







PHP Programmer - interactivetools.com

Re: [greg] Display Certain Records

thank you very much, it worked great!