"If" " and" syntax problem

5 posts by 3 authors in: Forums > CMS Builder
Last Post: December 18, 2008   (RSS)

By gkornbluth - December 17, 2008

I know that I've seen this on the forum before but I cant seem to locate it.

I'm trying to put an "if" statement together that looks for 2 fields to be empty and if both are empty, shows a block of text.

I've tried:

<?php if (!$record['print_price']) and ($!record['full_description']):?>NO INFORMATION AVAILABLE<?php endif ?>

and as many variations on the theme as I can think of, but obviously my syntax is all screwy.

Anyone know the correct syntax?

Also, is there a resource anyone uses that answers these types of syntax issues in a similar context? I've tried a number of php websites but they leave me even more confused.

Thanks,

Jerry
The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

Re: [gkornbluth] "If" " and" syntax problem

By ross - December 17, 2008

Hi.

Thanks for posting!

Instead of the word "and" could you try "&&" like this:

<?php if (!$record['print_price']) && ($!record['full_description']):?>

Let me know how you make out with that :)
-----------------------------------------------------------
Cheers,
Ross Fairbairn - Consulting
consulting@interactivetools.com

Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/

Re: [gkornbluth] "If" " and" syntax problem

By Dave - December 17, 2008

And remove the extra ) and (. Then replace $! with !$. sometimes I add spaces to make it clearer:

<?php if ( !$record['print_price'] && !$record['full_description'] ): ?>
...
<?php endif ?>


Hope that helps!
Dave Edis - Senior Developer
interactivetools.com

Re: [gkornbluth] "If" " and" syntax problem

By Dave - December 18, 2008

Jerry, thanks for posting back. Great to hear it's working! :)
Dave Edis - Senior Developer
interactivetools.com