Hi Folks,
I am currently hacking Lucid Calendar and need to do a fairly complex query (complex for me anyway ).
I am adding a function to show the next 5 events on my index page. I use the following sql with PHP
$query = "SELECT * FROM calendar_messages ORDER BY msg_year, msg_month, msg_day LIMIT 0,5";
This works in as far as it gives the first 5 entrys in the DB. I want to limit these to the first 5 AFTER todays date. My script has variables for day, month and year
I know I need to use a WHERE clause here but there will have to be one for month, day and year.
I tried many variations of..
$query = "SELECT * FROM calendar_messages ORDER BY msg_year, msg_month, msg_day LIMIT 0,5 WHERE msg_year >= '$year',msg_month >= '$month', msg_day >= '$day'";[/red]
It does not work.
Can anyone helpme to construct this query?
Thanks in advance
Mike
Table Dump...
CREATE TABLE calendar_messages (
msg_id int(11) NOT NULL auto_increment,
msg_month int(2) NOT NULL default '0',
msg_day int(2) NOT NULL default '0',
msg_year int(4) NOT NULL default '0',
msg_title tinytext NOT NULL,
msg_text text NOT NULL,
msg_poster_id varchar(11) NOT NULL default '0',
msg_recurring tinytext,
msg_active int(1) NOT NULL default '0',
PRIMARY KEY (msg_id)
) TYPE=MyISAM;
I am currently hacking Lucid Calendar and need to do a fairly complex query (complex for me anyway ).
I am adding a function to show the next 5 events on my index page. I use the following sql with PHP
$query = "SELECT * FROM calendar_messages ORDER BY msg_year, msg_month, msg_day LIMIT 0,5";
This works in as far as it gives the first 5 entrys in the DB. I want to limit these to the first 5 AFTER todays date. My script has variables for day, month and year
I know I need to use a WHERE clause here but there will have to be one for month, day and year.
I tried many variations of..
$query = "SELECT * FROM calendar_messages ORDER BY msg_year, msg_month, msg_day LIMIT 0,5 WHERE msg_year >= '$year',msg_month >= '$month', msg_day >= '$day'";[/red]
It does not work.
Can anyone helpme to construct this query?
Thanks in advance
Mike
Table Dump...
CREATE TABLE calendar_messages (
msg_id int(11) NOT NULL auto_increment,
msg_month int(2) NOT NULL default '0',
msg_day int(2) NOT NULL default '0',
msg_year int(4) NOT NULL default '0',
msg_title tinytext NOT NULL,
msg_text text NOT NULL,
msg_poster_id varchar(11) NOT NULL default '0',
msg_recurring tinytext,
msg_active int(1) NOT NULL default '0',
PRIMARY KEY (msg_id)
) TYPE=MyISAM;