"If" " and" syntax problem
5 posts by 3 authors in: Forums > CMS Builder
Last Post: December 18, 2008 (RSS)
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
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
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
<?php if ( !$record['print_price'] && !$record['full_description'] ): ?>
...
<?php endif ?>
Hope that helps!
interactivetools.com
Re: [Dave] "If" " and" syntax problem
By gkornbluth - December 17, 2008 - edited: December 17, 2008
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="<?php echo $record['_link'] ?>"><?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="<?php echo $record['_link'] ?>"><?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="<?php echo $record['_link'] ?>"><?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>
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
interactivetools.com