Problem with syntax for "if"

4 posts by 3 authors in: Forums > CMS Builder
Last Post: March 26, 2009   (RSS)

By eduran582 - March 25, 2009

Hey Dave,

I'm trying to check a table field (display_date) for the word "(Pending)" (without the quotes) and if it exists, have it say one thing and if it does not exist, say something else. I'm using the following but I'm doing something wrong because it always shows the second selection (Register for Class) even when the (Pending) is present in the field:

<?php if (!$class_datesRecord['display_date'] == "(Pending)"): ?>
No Dates Available
<?php else: ?>
Register for Class
<?php endif; ?>

Probably something simple but I'm stuck. Any ideas? [crazy]

Eric

Re: [eduran582] Problem with syntax for "if"

By zip222 - March 26, 2009

I don't think you need the exclamation point. If the field contains "(Pending)" then it definitely exists.

Re: [eduran582] Problem with syntax for "if"

By ross - March 26, 2009

Hi Eric

I also think you'll want to try that without the "!" at the start. What that is saying is "If the value doesn't equal (Pending) do something. I think what you want is, if the value does equal (Pending), do something.

Try without that "!" and let us know :).
-----------------------------------------------------------
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/