Jump to content

Archived

This topic is now archived and is closed to further replies.

Reg Web

Expire row in MySQL - Is it possible?

Recommended Posts

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?

Share this post


Link to post
Share on other sites
yes
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
[code]
<?php
$connection = mysql_connect('localhost', '*****', '*****');
mysql_select_db('table');
$query = "DELETE FROM table WHERE "delete parameters are met";
mysql_query($query)or die ('Error in query: $query. ' . mysql_error());

?>
[/code]

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

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.