Boolean - display only checked items
Hello,
I have a pod setup and displaying correctly on my site using something like below
<?php
$team = new Pod('special_offers');
$team->findRecords('RAND()', 4);
$total_members = $team->getTotalRows();
?>
I have added a new boolean field called 'Active' to the pod, how would I go about displaying only the checked Active records?
If I need to display more of my code here just let me know.
Any help would be really appreciated, thank you.
Alan
3 Answers
This should work:
<?php
$team = new Pod('special_offers');
$sqltxt = 't.active = "1"';
$team->findRecords('name ASC', 1000, $sqltxt);
$total_members = $team->getTotalRows();
?>
(I took the rand() out, although that can be left in, I just like 'em sorted alphabetically and 1000 records which could be any number you choose of course)
I do recommend writing the sqltxt in a var for clarity.. certainly when it becomes more complicated
edited Sep 1 '10 at 8:05
I thought it would have been something like
$team->findRecords('RAND()', 4, "t.active = '0'");
but it just causes an sql error
Thanks for the help tomhermans. Worked Great !
The 'active' column was actually in a related pod, so I used.
$team = new Pod('special_offers');
$sqltxt = 'related_company.active = "1"';
$team->findRecords('RAND()', 4, $sqltxt);
$total_members = $team->getTotalRows();
It's to display special offers from companies that have signed up so I wanted it random so no one gets more preference than the other. Only displaying 4 as this is the homepage call.
Thanks again
edited Sep 2 '10 at 9:05


