Page 1 of 1

New to PHP

Posted: Fri Nov 15, 2002 3:17 pm
by fatguy
I am creating an online calendar where on the homepage it displays the next two upcoming events. I know how to limit it to two, but how do I have it automatically find the next two upcoming events. Sorry, this is probably a cinch for you all to answer. [/quote]

Posted: Fri Nov 15, 2002 3:38 pm
by volka
where and how do you store events?
e.g. take a look at http://www.mysql.com/doc/en/Date_and_ti ... tions.html

Posted: Fri Nov 15, 2002 3:43 pm
by fatguy
I have everything stored in a calendar table. They are arranged by date eg. (2002-12-03)... would this work?.....

SELECT * FROM (table) order by cal_date desc limit 2

Posted: Sat Nov 16, 2002 1:22 am
by volka
this returns always the two recordsets with the 'smallest' value in cal_date. If you delete old records this may work but you may try

Code: Select all

SELECT * FROM tablename WHERE cal_date>=NOW() order by cal_date desc limit 2

Posted: Sat Nov 16, 2002 1:31 am
by MeOnTheW3
volka is right, however you may wish to use the datetime field to make your schelude up to the second, instead of up to the day.

Posted: Mon Nov 18, 2002 11:00 am
by fatguy
Thanks.... Looks like it worked..

Posted: Mon Nov 18, 2002 6:32 pm
by fatguy
arghhh.... jumped the gun on the "it worked" schpeal....
I can get it to display the first two events in the table... but what if I don't want to manually delete old events.. can it automatically recognize the date and display the next two... or automatically delete an event after it occurs?

Posted: Wed Nov 20, 2002 3:38 pm
by fatguy
guess not?