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)

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?

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