filter listings by two categories + today's date forward

4 posts by 3 authors in: Forums > CMS Builder
Last Post: March 31, 2010   (RSS)

Re: [Deborah] filter listings by two categories + today's date forward

By Chris - March 30, 2010

Hi Deborah,

Well, you definitely need parenthesis around your OR condition:

'where' => ' (category LIKE "%\tMusic - Events\t%" OR category LIKE "%\tArt - Events\t%") AND (NOW() + INTERVAL 365 DAY) >= date AND date >= TIMESTAMP(CURDATE(), "00:00:00") ',

Does that help? Please let me know if you have any questions.
All the best,
Chris

Re: [chris] filter listings by two categories + today's date forward

By Deborah - March 30, 2010

Chris,

Your correction seems to be just what was needed. Thank you so much! I shall document example that for future projects.

Deborah

Re: [Deborah] filter listings by two categories + today's date forward

By Dave - March 31, 2010

A tip for anyone with similar issues: MySQL ignores extra whitespace, so I often add extra spaces and line breaks to make it easier for me to read the code at a glance. Example:

'where' => '(category LIKE "%\tMusic - Events\t%" OR category LIKE "%\tArt - Events\t%")
AND (NOW() + INTERVAL 365 DAY) >= date
AND date >= TIMESTAMP(CURDATE(), "00:00:00") ',


And I often add extra parenthesis as well, as I've been bitten by this more than a few times myself! :)
Dave Edis - Senior Developer
interactivetools.com