"If" " and" syntax problem

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

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 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: [Dave] "If" " and" syntax problem

By gkornbluth - December 17, 2008 - edited: December 17, 2008

thank you both,

Here;s what I cobbled together, although I have a feeling that it's not the most elegant approach and I'm open to suggestions. This works with Milkbox which is a lightbox derivative so that when the various combination of selling price and description occur, the appropriate message appears under the title.

http://www.elleschorrphotography.com/cmspeople4.php

<table border="0" id="gallery" cellspacing="0" cellpadding="10" align="center">
<tr valign="middle">
<?php foreach ($peopleRecords as $record): ?><?php foreach ($record['image'] as $upload): ?>
<td align="center" valign="middle" <?php echo $record['border'] ?> width="15%">
<div align="center">
<?php if ($upload['hasThumbnail']): ?>
<a href="<?php echo $upload['urlPath'] ?>" rel="milkbox[people]" title="
<?php if (!$record['print_price'] && !$record['full_description']): ?>?php echo $record['title'] ?><?php endif ?>

<?php if ($record['print_price'] && !$record['full_description']): ?><a href=&quot;<?php echo $record['_link'] ?>&quot;><?php echo $record['title'] ?></a><br>Click title for more information or to buy a print.<?php endif ?>

<?php if ($record['print_price'] && $record['full_description']): ?><a href=&quot;<?php echo $record['_link'] ?>&quot;><?php echo $record['title'] ?></a><br>Click title for more information or to buy a print.<?php endif ?>

<?php if (!$record['print_price'] && $record['full_description']): ?><a href=&quot;<?php echo $record['_link'] ?>&quot;><?php echo $record['title'] ?></a><br>Click title for more information<br />about this image.<?php endif ?>">

<img src="<?php echo $upload['thumbUrlPath'] ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight']?>" /></a>
<?php endif; ?>
</div></td>
<?php $maxCols=7; if (@++$count % $maxCols == 0): ?></tr><tr><?php endif; ?>
<?php endforeach ?>
<?php endforeach ?>
</tr>
</table>
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 Dave - December 18, 2008

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