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!
Thanks!
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:
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
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
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:
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
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
PHP Programmer - interactivetools.com
Re: [greg] Display Certain Records
thank you very much, it worked great!