Hello Guys,
My problem here is I want to check every row of the data if it's in the range of 2 days before today. and will send the email of it's name who fit the condition of 2days before.
<?php
//********************************************************
//2008/07/16 Yoshifumi Tagawa
//********************************************************
$date_today = date("Y/m/d H:i:s");
//********************************************************
//No Cache
//********************************************************
header("Content-Type: text/html; charset=文字コード");
header("Expires: Thu, 01 Dec 1994 16:00:00 GMT");
header("Last-Modified: ". gmdate("D, d M Y H:i:s"). " GMT");
header("Cache-Control: no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
//********************************************************
//Include File
//********************************************************
include ("../../include.php");
//********************************************************
//Get DB Visitor List Data
//********************************************************
$dsn = "VISITOR_LIST";
$usr = "";
$pwd = "";
$selyear=$_REQUEST["selyear"];
$sql = "SELECT * ";
$sql .="FROM LIST ";
$sql .="WHERE RELEASE = 1 ";
$sql .="AND (TEMP_FLG IS NULL or TEMP_FLG ='') ";
$list = GetDb_Odbc($dsn,$usr,$pwd,$sql);
if (!$list)
{
exit("Error in SQL");
}
echo "<table><tr>";
echo "<th>DEPARTURE_DATE</th>";
for($i_row=0; $i_row<count($list); $i_row++){
$DEPARTURE_DATE = $list[$i_row]["DEPARTURE_DATE"];
}
$ddate = strtotime($DEPARTURE_DATE); //--> which results to 1332866820
$tdate = strtotime("now");
echo ($tdate),"<br> ";
echo ($ddate),"<br> ";
$total = $tdate - $ddate;
if ($total >=86300 && $total <=259199)
{
//define the receiver of the email
$to = 'aab_system-development@mhps.com';
//define the subject of the email
$subject = 'Test email';
//define the message to be sent. Each line should be separated with \n
$message = "Hello World!\n\nThis is my first mail.";
//define the headers we want passed. Note that they are separated with \r\n
$headers = "From: webmaster@example.com\r\nReply-To: webmaster@example.com";
//send the email
$mail_sent = @mail( $to, $subject, $message, $headers );
//if the message is sent successfully print "Mail sent". Otherwise print "Mail failed"
echo $mail_sent ? "Mail sent" : "Mail failed";
}
echo ($total);
//if ($ddate - $tdate >=86300 && $ddate - $tdate <=259199)
//{
//echo"Great";
//}
$yourdatetime = '2009-08-21 1.45 PM';
$timestamp = strtotime($yourdatetime);
//while (odbc_fetch_row($list))
//{
//$depdate=odbc_result($list,"DEPARTURE_DATE");
//echo "<tr> <td>$depdate</td>";
//}
//odbc_close($conn);
//echo"</table>";
//echo date("m/d/Y");
//if(date("m/d/Y") == $dend)
//{
// echo"String";
//}
?>