<html>
<head>
<title>Deleting all redundant orders</title></head>
<body bgcolor = "#CCDDFF">
<?
 /***************************************************************************
 *			killdata.php                   	                    *
 *                     	          				            *
 *   File Info:		  Delete redundant orders                           *
 *   Copyright:       Copyright 2003 http://www.128concepts.com             *
 *						                            *
 ***************************************************************************/
include("./config.php");
$table= "myorders";
$conn = @mysql_connect($server,$user,$password)
	or die("Cannot connect to database");
$rs = @mysql_select_db($database,$conn) 
	or die("Unable to view product image");
// delete sessions more than 2 days old
$today_date=date("Ymd");
$expired_date = $today_date - 2;
$sql = "SELECT * from $table WHERE date_added <= '$expired_date'";

$result = mysql_query($sql,$conn)
	or die("Cannot execute SQL query");

$nrows = mysql_num_rows($result);

#delete the stuff

if ($nrows > 0)
{
	$del =  "DELETE from $table WHERE date_added <= '$expired_date'";
	$results = mysql_query($del,$conn)
	or die("Cannot delete orders");
	echo("<br><br><br><br><br><center>Deleting of redundant orders done...</center>");
	echo("<br><center><a href = javascript:window.close('acePopup')>Close Window</a></center>");
}
else
{
	echo("<br><br><br><br><br><center>There are no redundant orders to delete !</center>");
	echo("<br><center><a href = javascript:window.close('acePopup')>Close Window</a></center>");
}


?>
  
</body>
</html>