New to PHP

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
fatguy
Forum Newbie
Posts: 5
Joined: Fri Nov 15, 2002 3:17 pm
Contact:

New to PHP

Post 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]
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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
fatguy
Forum Newbie
Posts: 5
Joined: Fri Nov 15, 2002 3:17 pm
Contact:

Post 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
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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
MeOnTheW3
Forum Commoner
Posts: 48
Joined: Wed Nov 13, 2002 3:28 pm
Location: Calgary, AB

Post 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.
fatguy
Forum Newbie
Posts: 5
Joined: Fri Nov 15, 2002 3:17 pm
Contact:

Post by fatguy »

Thanks.... Looks like it worked..
fatguy
Forum Newbie
Posts: 5
Joined: Fri Nov 15, 2002 3:17 pm
Contact:

Post 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?
fatguy
Forum Newbie
Posts: 5
Joined: Fri Nov 15, 2002 3:17 pm
Contact:

Post by fatguy »

guess not?
Post Reply