If, then statements pulling optional / list content from various tables

4 posts by 3 authors in: Forums > CMS Builder
Last Post: April 22, 2011   (RSS)

By (Deleted User) - April 22, 2011

I have a page that pulls in records using checkbox from the database ($videos). I would like to put in an IF, THEN statement that basically says SHOW this title IF videos appear.
<?php echo $service_support_mainRecord['videos_title'] ?>
but otherwise it should not show.

Here's the code I have for this area. I've tried various if statements around H2, but I think I'm using the wrong variables...
===============================
<h2 style="padding-top:20px;"><?php echo $service_support_mainRecord['videos_title'] ?></h2>

<?php $videosCount = 0;?>
<?php foreach ($videosRecords as $videos): ?>
<?php $videosCount ++; ?>
<?php if (($videosCount % 3) == 0): ?>
<div class="videospageR">
<?php echo $videos['video_code'] ?>
<div style="text-align:center;"><?php echo $videos['title'] ?></div>
</div>
<?php else: ?>
<div class="videospageL">
<?php echo $videos['video_code'] ?>
<div style="text-align:center;"><?php echo $videos['title'] ?></div>
</div>
<?php endif ?>
<?php endforeach ?>

Re: [kimamel] If, then statements pulling optional / list content from various tables

By zip222 - April 22, 2011

I think this is what you're looking for...

<?php if ($videosRecords): ?>
<h2 style="padding-top:20px;"><?php echo $service_support_mainRecord['videos_title'] ?></h2>
<?php endif ?>

Re: [kimamel] If, then statements pulling optional / list content from various tables

Hi Kimamel,

Actually you can set all kinds of complex conditions using if statements.

Like: <?php if ($your_tableRecord['your_field'] == 'apples'): ?>

for a single criteria, or for multiple criteria:


<?php if ($your_tableRecord['field_a'] == 'apples' && $your_tableRecord['field_b'] == 'bananas' && $your_tableRecord['field_c'] ==
'pears'): ?>

There are a lot of specific recipes regarding things that you can do with both simple and complex "if" statements in my CMSB Cookbook at http://www.thecmsbcookbook.com

Hope that helps...

Jerry Kornbluth
The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php