Boolean - display only checked items

0

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

asked Sep 1 '10 at 4:22

inspiration

7

add comment
enter at least 15 characters

3 Answers

0

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

answered Sep 1 '10 at 8:04

tomhermans

36

edited Sep 1 '10 at 8:05

add comment
enter at least 15 characters
0

I thought it would have been something like

$team->findRecords('RAND()', 4, "t.active = '0'");

but it just causes an sql error

answered Sep 1 '10 at 4:34

inspiration

7

add comment
enter at least 15 characters
0

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

answered Sep 2 '10 at 9:03

inspiration

7

edited Sep 2 '10 at 9:05

add comment
enter at least 15 characters