Below is my email.php. The code runs well until I try to calculate the number of rows for laptop warranty expired. The number of rows can be print out, but it does not contain the description for each laptop as stated in the code. May I know what should I do to fix this code ?
Edited :
For example, the content of email will be like this :
Dear IT Infra,
Total 125 of laptop are going to expire in less than 45 days.
Status : Loan
Laptop serial number: R8VMGFH
Date of expired:2013-01-17
Etc....(another 124 description of laptop)
It should displaying all these, but it does not now.
Email.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