Help with mysql select query

I am using a calendarix calendar on my band site and I found that I could create an “upcoming events” mini table listing events that match a specified category. (I don’t like their mini calendar - it just doesn’t work for what I need - overcomplicated.)

In the calendar db, there is a table called calendar_events and in that table there are two columns “day” and “month” which are stored as integers.

I am trying to figure out how to construct a query with a where clause that limits the entries to the events “greater than or equal to” today’s date, and I am having no luck.
I have tried using the php function iDate with the format (dm) which should give me the day and month in integer format. What I cannot figure out is how to split the day and month into the select query (ie SELECT * FROM calendar_events WHERE day>= ? AND month>= ? AND category=“2” ORDER BY date)

The question marks above are where I cannot figure out what to use.

I am kind of a noob, but I know enough to get myself into trouble. I am hoping some kind soul will help me out on this one.

Thanks in advance.

How about something like:

$sql = “SELECT * FROM calendar_events
WHERE (day >= " .date(“j”, time()) .” AND month= “.date(“n”, time()).” and category=“2” ) OR
(category=“2” AND month > “.date(“n”, time()).”) ORDER BY date"

(day >= " .date(“j”, time()) ." AND month= “.date(“n”, time()).” and category=“2” ) will grab all data that has a DAY => today but only for THIS month

(category=“2” AND month > “.date(“n”, time()).”) will grab ANY date with a Month greater than THIS month. Day is irrelevant at this point.

Totally brilliant, and works like a charm!

Thank you so much for your reply and your expertise. I am learning every day.


You make me blush :oops:

Anyway… Glad to help.

Sponsor our Newsletter | Privacy Policy | Terms of Service