Checking multiple fields for displaying lists.

8 posts by 2 authors in: Forums > CMS Builder
Last Post: November 24, 2008   (RSS)

By tsuluwerks - November 19, 2008

The system allows us to put in WHERE statements, ie:
$options['where'] = 'offering_type_1 = "Generations"'; // (ADVANCED) Additional MySQL WHERE conditions. Example: 'fieldname = "value"'

I would like for the system to check ALL fieldnames for the information in quotes, and display all the records that would match. Is there a PHP/MySQL wildcard that can do this?

I checked in with a programming friend who made the following (unsuccessful) recommendation:

you can not use wildcards in fieldnames.
You can use the OR statement in the query.
Example: $options['where'] = ' offering_type_1 = "Generations" OR fieldname2 = "Generations" OR fieldname 3= "Generations" ';

I replied with:

I gave the "OR" statement a try, but it's not pulling all of the information properly. It only reads the first option and ignores the rest.


He then made the following (unsuccessful) recommendation:

$options['where'] = ' ( offering_type_1 = "Generations" OR fieldname2 = "Generations" OR fieldname 3= "Generations" ) ';

I replied with:
That didn't work either. I tried it with the quotes as listed, and it gave me an error. When I put each option in its own set of brackets, it wouldn't render the page or return an error.


Is there a way to check multiple or all fields in a table to display in a list?

Thanks,
T

Re: [tsuluwerks] Checking multiple fields for displaying lists.

By Dave - November 19, 2008

Hi T,

Looks like you're using an older version of CMS Builder. We've updated the generated code a bit. That's bit though it's similar and will still work.

Try this:

$options['where'] = ' ( offering_type_1 LIKE "%Generations%" OR fieldname2 LIKE "%Generations%" OR fieldname3 LIKE "%Generations%" ) ';

LIKE lets you use wildcards such as % which mean (any number of characters).

This can also be put in the url like this:

yourViewer.php?offering_type_1,fieldname2,fieldname3_keyword=Generations

You can read more about the build in url searching features here:
http://www.interactivetools.com/docs/cmsbuilder/viewer_search.html

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

Re: [Dave] Checking multiple fields for displaying lists.

By tsuluwerks - November 19, 2008

Thanks Dave. I'll give it a try. I have another client using a newer version, and it's much easier. What can we do to get the latest version for all of our clients?

T

Re: [tsuluwerks] Checking multiple fields for displaying lists.

By Dave - November 19, 2008

Upgrades are by donation and you can download the latest zip here: http://www.interactivetools.com/upgrade/

I'd upgrade your clients one at a time just to make sure everything goes smoothly. But we've made the upgrade process simpler so now you can just upload all the folders instead of worrying about which ones should and shouldn't be uploaded.
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] Checking multiple fields for displaying lists.

By tsuluwerks - November 21, 2008

the LIKE statement isn't working either. We're having a similar issue on another page. I hope to figure this out or find an alternative solution.

Re: [tsuluwerks] Checking multiple fields for displaying lists.

By Dave - November 21, 2008

I'm pretty sure that code is valid. What is it doing? Just not returning any results? Can you attach the viewer file to this post so we can see the code?
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] Checking multiple fields for displaying lists.

By tsuluwerks - November 24, 2008

Hi, Dave, we found that the viewer works if we replace LIKE with OR. Thanks for your help!
T