Simple sorting records question

5 posts by 2 authors in: Forums > CMS Builder
Last Post: May 18, 2009   (RSS)

By avrom - May 15, 2009

Hi Dave,

I have the following detail viewer code:

list($business_profileRecords, $business_profileMetaData) = getRecords(array(
'tableName' => 'business_profile',
'limit' => '3',
'orderBy' => 'RAND()',
));

I also want to add to the above if the record has "directory_text" OR (not And) "directory_logo". So in other words if the record doesnot match "directory_logo" or "directory_text" it doesnot get selected as one of the 3 random records. I think this just a simple "where" statement but not exactly sure how to code that in.

Thanking you in advance,
Avrom :)

Re: [ross] Simple sorting records question

By avrom - May 15, 2009

Hi Ross,

Thanx for getting back to me :))

Sorry for not explaining quite clearly. The "directory_logo" and "directory_text" are checkboxes. If either one of them is checked then I want to display them in the records. If they are not checked then they won't get selected.

Does that make sense ? Cheers and thanx.

Avrom

Re: [virgodesign] Simple sorting records question

By avrom - May 15, 2009

This would be the right answer on that one:

you only want to pick from records that have something in either of those fields

Cheers
Avrom

Re: [virgodesign] Simple sorting records question

By ross - May 18, 2009

Hi Avrom

Definitely makes more sense now :).

What you are going to be looking for is something like this:

'where' => "directory_logo = 'something' OR directory_text = 'something else'",

You need to change the something and something else to the values that get set when you check those checkboxes. You can find that out by going to the section editor and clicking to modify the field. It will say what its checked value is.

Does that make sense? Let me know what you think :).
-----------------------------------------------------------
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/