What's wrong with this?

4 posts by 3 authors in: Forums > CMS Builder
Last Post: November 15, 2012   (RSS)

Hi Guys,

I've got a select field where I can select which item to insert on a page - which should work quite easily - but for some reason it isn't...

I've tested that the field is correct by just echoing it initially, and even though it's showing "a" on the page, it's not showing any of the resulting if statement.

What am I doing wrong?


<?php echo $detailRecord['modules']; ?>

<?php if ($detailRecord['modules'] == 'a'): ?><p>insert room types</p>
<?php elseif ($detailRecord['modules'] == 'b'): ?><p>insert contact form</p>
<?php else: ?>
<?php endif ?>

Cheers,

Tim (toledoh.com.au)

Re: [Toledoh] What's wrong with this?

By Codee - November 15, 2012

Maybe it IS working (mostly)...how about putting a test statement or something to print if it gets to the final<else> statement? Maybe it's printing nothing because it did not find 'a' nor 'b'... that's the only thing I can think of at the moment.

Re: [Toledoh] What's wrong with this?

By Dave - November 15, 2012

Is it a multi-value field? If so, those have values that are separated by tabs.

I always echo values surrounded by quotes, so I will notices stray spaces and tabs. eg:

$detailRecord['modules'] = "<?php echo $detailRecord['modules']; ?>"
Dave Edis - Senior Developer
interactivetools.com