This article has been dead for over three months
You
i want to send the mail , when product got expire from before and ondate and after day, in php i was used datediff mysql function with php, but if product expire date comes like 31-1-2012 , the differ value is not suit for my coding , plz help how to solve it ,
This is my coding
<pre><code><code>&lt;?php
$sql = mysql_query(&quot;SELECT * FROM supplier_product_det&quot;);
$results = mysql_num_rows($sql);
//echo '&lt;script&gt;alert(&quot;'.$results.'&quot;)&lt;/script&gt;';
if ($results &gt; 0)
{
for($i=0;$i&lt;$results;$i++)
{
while($rows = mysql_fetch_array($sql))
{
/* print_r($rows['expired_on']);?&gt; &lt;?*/
$exdate = $rows['expired_on'];
$curdate = date('Y-m-d');
$datedif = mysql_query(&quot;select datediff('&quot;.$curdate.&quot;','&quot;.$exdate.&quot;')&quot;);
while( $date = mysql_fetch_array($datedif) )
{
//echo $date['0'];
//echo $rows['pro_code'];
if (($date['0'])== 1)
{
if(($rows['mailcount'])!== $curdate)
{
$to = $rows['supplier'];
$subject = &quot;Product Expire Intimation&quot;;
$message = &quot;Dear Mr/Miss/Mrs
The Following Your Product Expired
Product Code:&quot;.$rows['pro_code'].&quot;
Product Name:&quot;.$rows['product_name'].&quot;
Product Expire Date:&quot;.$rows['expired_on'].&quot;&quot;;
$from = &quot;tone@bgrow.com&quot;;
$headers = &quot;From:&quot; . $from;
mail($to,$subject,$message,$headers);
$checkdate = mysql_query(&quot;update supplier_product_det set mailcount ='&quot;.$curdate.&quot;' where id='&quot;.$rows['id'].&quot;'&quot;) or die(mysql_error());
}
//echo $rows['supplier'];
}
if (($date['0'])== 0)
{
if(($rows['mailcount'])!== $curdate)
{
$to = $rows['supplier'];
$subject = &quot;Product Expire Intimation&quot;;
$message = &quot;Dear Mr/Miss/Mrs
The Following Your Product Expired
Product Code:&quot;.$rows['pro_code'].&quot;
Product Name:&quot;.$rows['product_name'].&quot;
Product Expire Date:&quot;.$rows['expired_on'].&quot;&quot;;
$from = &quot;tone@bgrow.com&quot;;
$headers = &quot;From:&quot; . $from;
mail($to,$subject,$message,$headers);
$checkdate = mysql_query(&quot;update supplier_product_det set mailcount ='&quot;.$curdate.&quot;' where id='&quot;.$rows['id'].&quot;'&quot;) or die(mysql_error());
}
//echo $rows['supplier'];
}
if (($date['0'])== -1)
{
if(($rows['mailcount'])!== $curdate)
{
$to = $rows['supplier'];
$subject = &quot;Product Expire Intimation&quot;;
$message = &quot;Dear Mr/Miss/Mrs
The Following Your Product will Expire Today
Product Code:&quot;.$rows['pro_code'].&quot;
Product Name:&quot;.$rows['product_name'].&quot;
Product Expire Date:&quot;.$rows['expired_on'].&quot;&quot;;
$from = &quot;tone@bgrow.com&quot;;
$headers = &quot;From:&quot; . $from;
mail($to,$subject,$message,$headers);
$checkdate = mysql_query(&quot;update supplier_product_det set mailcount ='&quot;.$curdate.&quot;' where id='&quot;.$rows['id'].&quot;'&quot;) or die(mysql_error());
}
//echo $rows['supplier'];
}
}
}
}
}
?&gt;</code></code></pre>