Display Alternative Results when Field is Blank

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

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: [greg] Display Alternative Results when Field is Blank

By sidcam - December 10, 2012 - edited: December 10, 2012

Awesome!

Kind of along this same line. Our postal codes in the US are six digits but can have an extra (optional) 4 digits behind them separated by a dash (i.e. 123456 or 123456-1234). I get this data in two separate fields. The main postal field is always filled out; The optional "extra four" field is only filled out about half the time.

My problem is the dash because it only needs to be there when there's data in the second field. I was looking at what you just did to see if it would work for this, but can't quite figure out how to insert a '-' in front of the field's data when the field is available.

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

Thanks, Sid

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