Help with if then statement

4 posts by 2 authors in: Forums > CMS Builder
Last Post: February 10, 2016   (RSS)

Saw this and thought i could help. Here is what I usual do in this case by using an if statement checking image size. So if the size is zero that indicates there is no image and goes to the next if statement:

<?php if (sizeof($record['quickship_image']) >= 1): ?>   

<?php foreach ($record['quickship_image'] as $upload): ?>
<?php if ($upload['isImage']): ?>
<a href="<?php echo $record['link'] ?>"><img src="<?php echo $upload['urlPath'] ?>" alt="" class="img-bord" width="150" height="150" border="0" /></a> <?php endif ?>
<?php break; ?>
<?php endforeach ?>

<?php elseif (sizeof($record['main_image']) >= 1): ?> 

<?php foreach ($record['main_image'] as $upload): ?>
<?php if ($upload['isImage']): ?>
<a href="<?php echo $record['link'] ?>"><img src="<?php echo $upload['urlPath'] ?>" alt="" class="img-bord" width="150" height="150" border="0" /></a> <?php endif ?>
<?php break; ?>
<?php endforeach ?>

<?php endif ?>

Dan Perez

I tested your code and it is showing both images.

It is working. I didnt refresh the page. Thank YOu.