I have this script that caclulates your next servicevisit based on what your miles per day, but when they only have one entry, the miles perday is 0, and what I want to do is if the value is zero, set the miles per day to 33.
$query = "SELECT MAX(CLOSEDATE), MIN(CLOSEDATE), CURDATE(), VIN, CUSTOMERNAME, MAX(MILEAGE), MIN(MILEAGE), miles_per_day FROM LUTHERSELLANDRECOMMEND GROUP BY VIN";
$result = mysql_query($query);
while ($row = mysql_fetch_array($result)) {
if($milesperday < '33'){
$mileage = $row["MAX(MILEAGE)"];
$date1 = $row["MIN(CLOSEDATE)"];
$date2 = $row["MAX(CLOSEDATE)"];
$datelate = date("Y-m-d" , (strtotime($date) + (60*60*24*90)));
$todaysdate = $row["CURDATE()"];
$dateexpire = date("Y-m-d" , (strtotime($todaysdate) + (60*60*24*90)));
$time1 = strtotime($date2);
$time2 = strtotime($todaysdate);
$time = @round($time2-$time1,0);
$datedifference = @round($time/60/60/24);
$projectedmileage = @round($mileage+($datedifference*$milesperday));
$projectedmaintenancedate = date("Y-m-d" , (strtotime($date2) + (60*60*24*90)));
}else{
$mileage = $row["MAX(MILEAGE)"];
$date1 = $row["MIN(CLOSEDATE)"];
$date2 = $row["MAX(CLOSEDATE)"];
$datelate = date("Y-m-d" , (strtotime($date) + (60*60*24*90)));
$todaysdate = $row["CURDATE()"];
$dateexpire = date("Y-m-d" , (strtotime($todaysdate) + (60*60*24*90)));
$time1 = strtotime($date2);
$time2 = strtotime($todaysdate);
$time = @round($time2-$time1,0);
$datedifference = @round($time/60/60/24);
$projectedmileage = @round($mileage+($datedifference*$milesperday));
$projectedmaintenance = @round(3000/$milesperday);
$projectedmaintenancedate = date("Y-m-d" , (strtotime($date2) + (60*60*24*$projectedmaintenance)));
}
}
Thanks in advance.