Hi I had a real estate web site and user/visitor can post their property into the database. Now What I need is After 15 days the post will be delete automatically. Please any give me the idea for doing this. "How to do delete using Date ?"
You can set up a cron job to run every day (or night) and have this query. If you can't have crons, you can run this script whenever the main page is loaded.
DELETE FROM Table
WHERE datecolumn < DATE(DATE_SUB(now() , INTERVAL 15 DAY))
Whare wxactly do i put this code?, my DB connection code looks like this:
$databasename='xxxx'; // Name of the database
$tablename='xxxx'; // Name of the table
$mysqladd='xxxx'; // Address to the MySQL Server - Usually localhost but could be an IP address
$mysqluser='xxxx'; // Your MySQL UserName
$mysqlpass='xxxx'; // Your MySQL Password
//CONNECT TO MYSQL
$link=mysql_connect($mysqladd, $mysqluser, $mysqlpass) or die('Could not connect to database: ' . mysql_error());
//CONNECT TO DATABASE
mysql_select_db($databasename, $link) or die('Could not connect to table: ' . mysql_error());
$query="SELECT * FROM xxxx ORDER BY Timestamp DESC";
while ($i < $num) :