IF/THEN Statement (PHP) for custom fields

3 posts by 2 authors in: Forums > CMS Builder
Last Post: December 22, 2007   (RSS)

By rasbro - December 21, 2007

I was wondering if anyone knew how I could use an if/then statement with PHP to say that if a custom field, such as product sale_price is empty, then display only the price, else display price and sale_price fields.

I know how to do the if/then statements in PHP but I am unsure of what value to specify for the empty field. Here is an example I am working with.

<?php if ($record['sale_price'] == "empty"): ?>
Price: $<?php echo $record['price'] ?><br/>
<?php else: ?>
Price: $<?php echo $record['price'] ?><br/>
Sale Price: $<?php echo $record['sale_price'] ?><br/>
<?php endif ?>

Thanks,
Brian

Re: [Dave] IF/THEN Statement (PHP) for custom fields

By rasbro - December 22, 2007

It works great Dave, thank you!