If less than X records

6 posts by 3 authors in: Forums > CMS Builder
Last Post: January 13, 2009   (RSS)

Hi, and happy new year!

Is it possible to write an IF statement saying:

IF there are less than 4 records in the table...

For example:
<?php if ($productsRecords QUANTITY < 4): ?>

Many thanks in advance
Rob

Re: [rjbathgate] If less than X records

By aev - January 13, 2009

Re: [rjbathgate] If less than X records

By Dave - January 13, 2009

Hi Rob,

You can check the record meta details (as suggested above) or the array count directly like this:

<?php if (count($productsRecords) < 4): ?>

Hope that helps!
Dave Edis - Senior Developer
interactivetools.com

Re: [rjbathgate] If less than X records

By Dave - January 13, 2009

Can you filter out records that aren't: "Display = 'Yes' " in the where? ie:

'where' => " online = 'Yes' AND Display = 'Yes' ",
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] If less than X records

Yes, sorry my mistake, Display is actually Online.

Working a treat with the above code, thanks again