How I make a list that only shows record that I have a contain value for a certain field?

5 posts by 3 authors in: Forums > CMS Builder
Last Post: October 28, 2008   (RSS)

By zrmiles - October 27, 2008

I have a list of records that I need filter so it only shows the records that have contain a certain value in a certain field. Is this possible using your CMS?

also, the record might have multiple values in that field, such as "community, utility". How do I make sure it shows up both in the list that contains only those with "community" and the one that contains only those with "utility"?

Thanks

Re: [zrmiles] How I make a list that only shows record that I have a contain value for a certain field?

By rjbathgate - October 28, 2008 - edited: October 28, 2008

Yeah, there sure is a way...

You just need a where statement in the php where you're calling the table, for example:

<?php

require_once "/home/public_html/cmsAdmin/lib/viewer_functions.php";


list($mytableRecords, $mytableMetaData) = getRecords(array(
'tableName' => 'mytable',
'where' => " myfield = 'community' ",
));


?>

So in this example, this line is the bit I've added

'where' => " myfield = 'community' ",

This line is saying display records only where the record in field 'myfield' is equal to community.

You'd just need to put in the relevant table and field names...

Does that help?

Re: [rjbathgate] How I make a list that only shows record that I have a contain value for a certain field?

By zrmiles - October 28, 2008

Yes, Thank you.

Is there any way to make it so it just has to contain the word, so even if it was "community, utility" in the field, it would still show up when I included the where statement for "community"

Re: [zrmiles] How I make a list that only shows record that I have a contain value for a certain field?

By rjbathgate - October 28, 2008

There'll probably be a way of simply sticking in wildcards around the keyword community, maybe

%community%
or
*community*

I'm not sure what would work thou, so maybe Donna or Dave can come to the rescue?!

Re: [zrmiles] How I make a list that only shows record that I have a contain value for a certain field?

By Dave - October 28, 2008

In a where statement it would be:
'where' => " myfield LIKE '%community%' ",

or in the url:
yourViewer.php?myfield_keyword=community

There's more on CMS Builders built in search engine functions here: http://www.interactivetools.com/docs/cmsbuilder/viewer_search.html

Hope that helps!
Dave Edis - Senior Developer
interactivetools.com