Display Certain Records

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

Re: [shawnpatoka] Display Certain Records

Hi,

You can use a get Records function to filter them out fairly easily.

I would do something like this:

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


If you change the names of the field and section in the example above, it should output only bars that are participating.

A tick box value is stored as 1 for ticked and 0 for unticked in CMS Builder.

Thanks
Greg Thomas







PHP Programmer - interactivetools.com

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!