PHP and MySQL tables

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
CameronO
Forum Newbie
Posts: 1
Joined: Thu Oct 28, 2010 3:00 pm

PHP and MySQL tables

Post by CameronO »

Evening Guys and Girls

I have a query about php and mysql and if it can be done or a recmmendation of the language to use.


I have a website that calls data from a database to show up and coming events of music gigs and festivals. It displays all this information in a formatted table.

I am happy with this but my question is when the gig is passed, I would like to it to be removed from the database and therefore not show on the site anymore automatically without author intervention.

Is there a function/query I can use to compare end date to system date world time etc and best use to impliment it.

Guidelines and a push in the right direction would be much appreciated

Kind regards

Cameron
klevis miho
Forum Contributor
Posts: 413
Joined: Wed Oct 29, 2008 2:59 pm
Location: Albania
Contact:

Re: PHP and MySQL tables

Post by klevis miho »

You should get the date from the gig(from the database) and compare it to the date now.
If the date of the gig is smaller than the date now, then delete that gig from the db.
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

Re: PHP and MySQL tables

Post by Eran »

You might want to keep those gigs for historical reference, but just not show them on the site. You can change the database query that fetches the gigs to filter out gigs that have taken place already. Something like

Code: Select all

WHERE gigs.performance_time > NOW()
Where gigs is the table and performance_time would be the relevant column.
klevis miho
Forum Contributor
Posts: 413
Joined: Wed Oct 29, 2008 2:59 pm
Location: Albania
Contact:

Re: PHP and MySQL tables

Post by klevis miho »

Or, run a cronjob once a day, to remove the gigs.
Post Reply