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: [zip222] If, then statements pulling optional / list content from various tables

By (Deleted User) - April 22, 2011

Perfect. Thank you. I was trying to stuff too much into my if statement.