Display Alternative Results when Field is Blank

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

By sidcam - December 10, 2012

I'm displaying this field in a prominent position on a record page:

<?php echo htmlencode($listing_resiRecord['square_footage']) ?>

But half the time the field is blank and I'd really love it to display a standard answer like "N/A" or "Not Available" instead of just running into the next field title.

Is there a way to insert an if/then or if/else into that statement?

Thanks, Sid

Re: [sidcam] Display Alternative Results when Field is Blank

Hi Sid,

Something like this should work:


<?php echo (@$listing_resiRecord['square_footage'])? htmlencode($listing_resiRecord['square_footage']) : 'N/A' ; ?>


So if $listing_resiRecord['square_footage'] exists and contains content then it will be echoed, else N/A will be echoed instead.

Thanks!
Greg Thomas







PHP Programmer - interactivetools.com

Re: [sidcam] Display Alternative Results when Field is Blank

Hi Sid,

Your fairly close with the code you had in the previous post, you just need to modify it slightly:

<?php echo (@$listing_resiRecord['postal_extrafour'])? htmlencode($listing_resiRecord['postal_extrafour']).' - ' : '' ; ?>

Thanks
Greg Thomas







PHP Programmer - interactivetools.com