checkboxes... troubling me again!

5 posts by 4 authors in: Forums > CMS Builder
Last Post: February 24, 2011   (RSS)

By Deborah - August 4, 2010

Those pesky checkbox fields cause me continual grief. I have tried every combination of code used successfully on other projects ((sigh)), and yet I can't figure out where I've gone wrong here. I either see the last three records entered (with disregard to the "favorite blog" checkbox, or I see no records at all.)

I have a checkbox field named favorite_blog with field values of Yes and No.

Header code:
list($blogRecordsFav, $blogMetaData) = getRecords(array(
'tableName' => 'blog',
'limit' => '3',
'allowSearch' => false,
'where' => " favorite_blog LIKE '%\Yes\t%' ",
));

HTML code:
<ul>
<?php foreach ($blogRecordsFav as $record): ?>
<li><a href="<?php echo htmlspecialchars ($record['_link']) ?>"><?php echo htmlspecialchars ($record['title']) ?>
<?php foreach ($record['favorite_blog_photo'] as $upload): ?>
<img src="<?php echo htmlspecialchars ($upload['thumbUrlPath']) ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" alt="" /></a></li>
<?php endforeach ?>
<?php endforeach ?>
</ul>

The above code displays nothing. Is there anything obviously wrong? (a v2.4 site, by the way)

Would sincerely appreciate any assistance.
~ Deborah

Re: [Deborah] checkboxes... troubling me again!

By Chris - August 4, 2010

Hi Deborah,

Try replacing:

'where' => " favorite_blog LIKE '%\Yes\t%' ",

...with:

'where' => " favorite_blog = 1",

Does that help? Please let me know.
All the best,
Chris

Re: [Deborah] checkboxes... troubling me again!

By sublmnl - February 23, 2011

hate to revive an old post but this was killing me.
I had to change a regular list option into a multiple select checkbox list for a client.
I made the usual 'where' call above the head tag for 'Monday'.
Then I was pulling my hair out until I found this old post and came up with the answer.

'where' => "day_of_week2 LIKE '%\Monday\t%' ",

You guys should put that in the Documentation.
[crazy]

Re: [sublmnl] checkboxes... troubling me again!

By Jason - February 24, 2011

Hi,

You'll want to make sure you have tab characters on either side of your value like this:

'where' => "day_of_week2 LIKE '%\tMonday\t%' ",

Thanks for the suggestion. We'll looking into adding some more information on how these lists work.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/