simple where filter problem

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

By rez - November 6, 2008

Hello. I am creating a restaurant menu. I decided to make my editor contain:

1. category - a drop menu of categories to choose from. This field name is category, one of the options is called mezza.

2. title

3. price

3. description

All I want to do is filter the results to display all of a particualar category from the drop menu called "Mezza".

list($rmenuRecords, $rmenuMetaData) = getRecords(array(
'tableName' => 'rmenu',
'where' => 'category = Mezza',
));




And in the body i have a foreach with tags like:

<?php echo $record['title'] ?>




I get this in the browser:

getRecords(rmenu) MySQL Error: Unknown column 'Mezza' in 'where clause'

Please let me know what i am doing wrong. I guess the column name is category and the entry is "Mezza" but i don't know how to code it. I looked around the forum but still don't get it.


Thanks.

Re: [rez] simple where filter problem

By rez - November 6, 2008

Ok. Searching a different way, i have come up with this:

list($rmenuRecords, $rmenuMetaData) = getRecords(array(
'tableName' => 'rmenu',
'where' => " category = 'Mezza' ",
));

That doesn't give me any errors but I don't get any records listed either. So My problem must be something to do with the naming, or what's a field versus column etc.

Again, Mezza is selected by the client and is an option in the editor, in a drop menu. Mezza, From the Grill, Sandwiches, etc.

CMS Editor "Menu" type is multi, category filed name is category. category field type is list (drop menu). Table name is rmenu.

Thanks for any help.

Re: [rez] simple where filter problem

By Dave - November 6, 2008

Hi rez,

Try putting quotes around the word:

'where' => 'category = "Mezza"',

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

Re: [Dave] simple where filter problem

By rez - November 6, 2008

I think we were writing at the exact same time. :)

I did the quotes thing and think that was a problem, but now using that statement doesn't seem to be the right way to list the categories from the drop menu.

Please see my post above.

Re: [rez] simple where filter problem

By Dave - November 6, 2008

Also, another even simpler way to do this is with an url (remove the 'where' first):

yourViewer.php?category=Mezza

You can read more about the built in search and filtering options here:
http://www.interactivetools.com/docs/cmsbuilder/viewer_search.html
Dave Edis - Senior Developer
interactivetools.com