USING THE NUMBER OF RECORDS MEETING A MYSQL QUERY TO CHANGE WHAT A VIEWER SHOWS - Feb 1st, 2011


I had a page with a number of "Where" statements setting the criteria for which records wound appear on groups on a
page.

What my client wanted to do was hide all reference to any group of records where there were no records that met those
criteria.

Example. The heading HAPPENING THIS WEEK if there were no records with start dates falling within the next 7 days.

Here's the simple if statement code that worked for me.



<?php
list($eventsRecords, $eventsMetaData) = getRecords(array(
'tableName' => 'events',
'where' => 'start_date > TIMESTAMP(NOW()+ INTERVAL 7 DAY)',

'orderBy'=> 'end_date ASC',
));

?>

<?php if (!$eventsMetaData['totalRecords'] == 0): ?>

Show this code....

<?php else: ?>

Show some other code...

<?php endif ?>




The materials on this web site have been created for use with CMS Builder content management software. CMS Builder software is published and licensed for use by InteractiveTools.com. Please contact Interactive Tools for information on the downloading of the software or the purchasing of licenses.


Terms of Service