Jump to content


Expire row in MySQL - Is it possible?

  • Please log in to reply
1 reply to this topic

#1 Reg Web

Reg Web
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 29 October 2006 - 12:36 PM

Hi there!

I am looking for a script which will enable me to tell the MySQL table to automatically delete a row upon a certain date and time.

Is this possible?

#2 paul2463

  • Members
  • PipPipPip
  • Advanced Member
  • 955 posts
  • LocationUK

Posted 29 October 2006 - 01:24 PM

you write a php script that will check over the database to delete all the rows you want it to such as:-

code for deleteRows.php
$connection = mysql_connect('localhost', '*****', '*****');
$query = "DELETE FROM table WHERE "delete parameters are met";
mysql_query($query)or die ('Error in query: $query. ' . mysql_error());


then set up a cron job on your server to run the script when you want it running, once a day , once an hour or whatever
you cannot affect the past but you can ruin a perfectly good present by worrying about the future

The <A HREF="http://www.php.net/d...php">MANUAL</A> is actually a useful resource

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users