Display Button for more if paid record
3 posts by 2 authors in: Forums > CMS Builder
Last Post: December 4, 2009 (RSS)
By Liz1001 - December 4, 2009
I have one more question. There are two types of listing - paid and free. The free listing should not display a button to 'view more' however the paid listing should.
I added a field to the database called 'level' if the box is checked then they have paid. I am using the following code to display the 'More Information' button but not having much luck, could you see if I missed something obvious or am going about this the wrong way - really appreciate your help!
<!--Show More info Button if paid listing-->
<?php foreach($business_listingRecords as $record); ?>
<?php if ($record['level'] =='1'): ?>
<a href="<?php echo $record['_link'] ?>"><img src="images/more_information.jpg" width="109" height="26" hspace="40" vspace="10" /></a>
<?php elseif ($record['level'] == '0'): ?>
<?php echo 'Sign Up' ?>
<?php endif ?>
Also, I need to talk to someone to cost out how much it would be to have you guys make the form at http://mormonbusiness.com/submit-a-business.php dynamic so it automatically places the form fields into the database record.
Thanks
Liz
I added a field to the database called 'level' if the box is checked then they have paid. I am using the following code to display the 'More Information' button but not having much luck, could you see if I missed something obvious or am going about this the wrong way - really appreciate your help!
<!--Show More info Button if paid listing-->
<?php foreach($business_listingRecords as $record); ?>
<?php if ($record['level'] =='1'): ?>
<a href="<?php echo $record['_link'] ?>"><img src="images/more_information.jpg" width="109" height="26" hspace="40" vspace="10" /></a>
<?php elseif ($record['level'] == '0'): ?>
<?php echo 'Sign Up' ?>
<?php endif ?>
Also, I need to talk to someone to cost out how much it would be to have you guys make the form at http://mormonbusiness.com/submit-a-business.php dynamic so it automatically places the form fields into the database record.
Thanks
Liz
Re: [Liz1001] Display Button for more if paid record
By Dave - December 4, 2009
Hi Liz,
It looks right, but for records that were created _before_ you added that field they'll have a value of null (or blank) for "level". You can actually just test the variable by itself to see if it contains a value that isn't zero or blank. Try this instead:
If that doesn't work, have a look to see what the value is for level with this debugging code:
Level value is '<?php $record['level'] ?>'<br/>
Let me know if that works for you!
It looks right, but for records that were created _before_ you added that field they'll have a value of null (or blank) for "level". You can actually just test the variable by itself to see if it contains a value that isn't zero or blank. Try this instead:
<?php if ($record['level']): ?>
<a href="<?php echo $record['_link'] ?>"><img src="images/more_information.jpg" width="109" height="26" hspace="40" vspace="10" /></a>
<?php else: ?>
Sign Up
<?php endif ?>
If that doesn't work, have a look to see what the value is for level with this debugging code:
Level value is '<?php $record['level'] ?>'<br/>
Let me know if that works for you!
Dave Edis - Senior Developer
interactivetools.com
interactivetools.com
Re: [Dave] Display Button for more if paid record
By Liz1001 - December 4, 2009
Dave that worked perfectly! Makes sense as that filed was added after the listings were created. thanks.