Jump to content


Photo

Auto delete row after event date has passed


  • Please log in to reply
5 replies to this topic

#1 frescue33

frescue33
  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 25 June 2006 - 07:37 PM

I have a table i am using to pull event information from to list upcoming events. Among others the table contains a 'startdate' and 'enddate' column (allowing for multiple day events). With each event being a new row. I was thinking something allong the lines of: IF currentdate > enddate DELETE row... But I am new to PHP so I have no idea how to script this part of the event manager. Any and all help would be appreciated.

#2 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,021 posts

Posted 25 June 2006 - 08:01 PM

mysql_query("DELETE FROM event_table WHERE enddate < CURDATE()";

If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#3 robos99

robos99
  • Members
  • PipPipPip
  • Advanced Member
  • 55 posts

Posted 26 June 2006 - 06:24 AM

Is CURDATE a unix timestamp or the MySQL date format?

#4 johnnyk

johnnyk
  • Members
  • PipPipPip
  • Advanced Member
  • 126 posts

Posted 26 June 2006 - 06:30 AM

It's a MySQL date function. It returns the current date in YYYY-MM-DD format.
[a href=\"http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html\" target=\"_blank\"]http://dev.mysql.com/doc/refman/5.1/en/dat...-functions.html[/a]

If you need a unix timestamp, use UNIX_TIMESTAMP() instead.
(same page, lower down)
Rediscover the Web:
<a href="http://www.spreadfir...;t=219"></a><br />

#5 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,021 posts

Posted 26 June 2006 - 06:30 AM

DATE format.

$res = mysql_query("SELECT CURDATE()");
echo mysql_result($res,0); // ----> 2006-06-26
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#6 robos99

robos99
  • Members
  • PipPipPip
  • Advanced Member
  • 55 posts

Posted 26 June 2006 - 07:38 AM

Oh ok, thought so. Just making sure I haven't been typing extra code all this time, haha.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users