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: [ross] Problem with syntax for "if"

By eduran582 - March 26, 2009

Thanks guys for the input!

I neglected to tell you I had tried with and without the "!" and it made no difference. HOWEVER, I figured out what the problem was and have since corrected it.

I had two sections in the file, one was the class description source and the other was the available dates for that class. I wanted to be able to show the user a link to the registration page IF there were class dates available and not show the link if there were not. As this notation came before the actual list of available dates, it was simply taking the first instance of the available dates for ALL the classes (all the class dates for various classes are contained in one section). What I had to do was use the same code, slightly modified, that I was using to show the class dates for THAT particular class and if the dates listed were equal to or after today's date then show the link to the registration. I did this by using the actual date field instead of the "listed date" (the date or date range that was listed for the user in the schedule). It was just a matter of checking the correct field [crazy]

Now when a particular class description is opened up, the user can see first if there are class dates available and if there are, be allowed to click on the link that takes them to the registration page, which lists only those dates available to select even though past dates, grayed out, are listed on the description page.

Thanks again for your replys!

Eric