Have an account? Sign in
Login  Register  Facebook
Hide after date/time past
Hello there!
I'm making an event script and i have done the add and edit page for that but now i want to add a function to make an event disappear when it's final date is reached. For ex:
I have this fields in the db:
  • EvID
  • EvName
  • EvImg
  • EvTxt
  • EvDateAdd
  • EvDateExpiry
  • EvAuthor
  • EvActive

EvDateAdd is the current date/how, the date/hour when the event is recorded in the database and i'm using NOW() in the sql query to get that.
Now, i need a way to add the date at EvDateExpiry for the expiration date.This (i suppose)can be made by a calendar but the problem on it (except that i don't know how to integrate a calendar in it) cannot be add the time too in the same field. If i will do it with a calendar script, i should add a new field in the db EvHourExpiry, i suppose...ore you can give me any other idea.
...Ok...i suppose that i have made this changes in the admin area...now, how to make the event disappear when the date and time combination is reached?
P.S. EvActive is a check button that have 2 values: Yes(event is active and appear in the page) and NO (event is inactive and cannot be seen on the user page)

Thank you very much ;) and hope that you will help me!
Started: September 22, 2011 Latest Activity: September 22, 2011 hide show php expiry
3 Answers
Many thanks Jooria. Do you know that u r the best? ;) I'll try it but i'm so sure that it will work. I'll update you as soon as i have a result!

Posted: Kleidi
In: September 22, 2011

I'm not quite clear if you want the expiration date to be user defined or automatically set based on the event add date. In he latter case, you can just use the MySQL date and time functions to populate the expiration date field:
DATE_ADD(NOW(), INTERVAL 1 DAY);
Once you have the expiration date, you can use simple SQL to find all records that have expired:
SELECT * FROM <table> WHERE EvDateExpiry <= NOW()
This would have to be run periodically outside your web application, e.g. from a script triggered by a cron job if you're on a Unix-based system.My

Posted: MacOS
In: September 22, 2011

it seems the problem has no relation to mysql but rather to HTML/JS. Start from the text field with 2010-11-06 value and then develop some other interface eventually. As for disappearing records you have just select only unexpired records. SELECT * FROM table WHERE EvDateExpiry < NOW(). That\'s all. It\'s the way databases works. Just select appropriate records

Posted: MacOS
In: September 22, 2011

Your Answer

xDo you want to answer this question? Please login or create an account to post your answer