Greater than one upload show >=1

2 posts by 2 authors in: Forums > CMS Builder
Last Post: February 15, 2013   (RSS)

By Mikey - February 14, 2013

I'm very tired, so this may sound like a stupid question, but I've been struggling with it for about 45 minutes now and I just need to get it figured out and working, so I can hit the sack...

I'm using an if statement to see if an image has been uploaded and if so, it loads a slide show. However, the slide show needs at least two uploads to actually be a slide show. So I'd like to keep the slide show form displaying if there are not enough images uploaded. Below is my if statement... You can see I'm trying to use greater < than 1 to determine if more than one image is uploaded. Anyone have a suggestion to get this working?

I've tried all the scenarios below with no success:

<?php elseif (sizeof($homepageRecord['banners']) >= 1): ?>

<?php elseif (sizeof($homepageRecord['banners']) >= '1'): ?>

<?php elseif ($homepageRecord['banners'] >= 1): ?>

<?php elseif ($homepageRecord['banners'] >= '1'): ?>

<?php elseif ($homepageRecord['banners'] > 1): ?>

<?php elseif ($homepageRecord['banners'] > '1'): ?>

<?php elseif ($homepageRecord['banners'] as $upload > 1): ?>

<?php elseif ($homepageRecord['banners'] as $upload >= 1): ?>

Thanks,

Zick

By gregThomas - February 15, 2013

Hi Zick,

You're close, you just need to use the PHP count function to check how many elements are in the array:

<?php if(count(@$homepageRecord['banners'] > 1): ?>
   <?php foreach($homepageRecord['banners'] as $banner): ?>
    //Display code goes here
   <?php endforeach; ?>
<?php endif; ?>

Thanks!

Greg

Greg Thomas







PHP Programmer - interactivetools.com