下面是我的email.php。代码运行良好,直到我尝试计算笔记本电脑保修到期的行数。可以打印出行数,但它不包含代码中所述的每台笔记本电脑的描述。我可以知道我该怎么做才能修复此代码吗?
编辑:
例如,电子邮件的内容将是这样的:
亲爱的 IT 基础设施,
总共 125 台笔记本电脑将在 45 天内到期。
状态 : 贷款
笔记本电脑序列号:R8VMGFH
失效日期:2013-01-17
等等....(笔记本电脑的另一种124描述)
它应该显示所有这些,但现在没有。
电子邮件.php:
<?php
// ======== get database data =======
include 'MasConnectDB.php';
$count = 0;
$sql = "SELECT Lap_Status, Lap_SN, Lap_War_Expiry FROM laptop WHERE
Lap_War_Expiry!='0000-00-00' AND Lap_War_Expiry!='' ";
$result = mysql_query( $sql ) or die('Query failed. ' . mysql_error() );
while( $row = mysql_fetch_array( $result ) ) {
$Lap_Status = $row['Lap_Status'];
$Lap_SN = $row['Lap_SN'];
$Lap_War_Expiry = $row['Lap_War_Expiry'];
date_default_timezone_set("Asia/Kuala_Lumpur");
$today_date = date('Y-m-d');
$expiry_date = $Lap_War_Expiry;
$timestamp = strtotime($expiry_date);
$warning_days = 45;
$seconds_diff = $warning_days * 24 * 3600;
$warning_timestamp = $timestamp - $seconds_diff;
$warning_date = date('Y-m-d', $warning_timestamp);
if ( $today_date >= $warning_date ) {
$message = $message." <div style='margin:30px 0px;'>
Status : $Lap_Status<br />
Laptop serial number: $Lap_SN<br />
Date of expired:$Lap_War_Expiry <br /></div>";
$count++;
}
}
$message ="Dear IT Infra,<br/><br /> Total $count of laptop are going to expire in
less than 45 days.<br /><br />";
require_once('class.phpmailer.php');
//Email goes here