I'm trying to determine number of days difference between the due duedate and current date and really need help.
<?php
mysql_connect("localhost", "root", "");
mysql_select_db(numbersdb) or die("Unable to select database");
$query = "SELECT taxrate FROM numbdata" ;
$result = mysql_fetch_assoc(mysql_query($query));
$taxrate = $result['taxrate'];
mysql_connect("localhost", "root", "");
mysql_select_db(oodb) or die("Unable to select database");
$query = "SELECT id, shipamt, duedate, charges, dayslate, tax, amtdue FROM oocust WHERE
DATEDIFF(NOW(), duedate) > 30 AND pd = ' '";
$result=mysql_query($query);
$num=mysql_numrows($result);
while($row = mysql_fetch_array($result))
{
$id = $row['id'];
$shipamt = $row['shipamt'];
$duedate = $row['duedate'];
$charges = $row['charges'];
$dayslate = $row['dayslate'];
$tax = $row['tax'];
$amtdue = $row['amtdue'];
$tax = $charges * $taxrate;
$amtdue = $charges + $tax + $shipamt;
// $dayslate = ;
$sql = "UPDATE oocust SET tax = '" . mysql_real_escape_string($tax) . "', amtdue = '" .
mysql_real_escape_string($amtdue) . "',dayslate = '" . mysql_real_escape_string($dayslate) . "' WHERE
id='".$id."'";$sql = "UPDATE oocust SET
tax = '" . mysql_real_escape_string($tax) . "',
amtdue = '" . mysql_real_escape_string($amtdue) . "',
dayslate = '" . mysql_real_escape_string($dayslate) . "'
WHERE id='".$id."'";
mysql_query($sql) or die("Update query failed.");
}
echo "Invoice Prep completed";
?>