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: [chris] checkboxes... troubling me again!

By Deborah - August 4, 2010

Hey, Chris.

I tried that 'where' code snkppet earlier today, but it was obviously in conflict with something else I had going (or not going) with the HTML code then.

All working great now. Thanks so much for your quick response!

~ Deborah

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

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]