954,604 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

PHP Mail Sending When Product got expire

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>&lt;code&gt;&amp;lt;?php

$sql = mysql_query(&amp;quot;SELECT * FROM supplier_product_det&amp;quot;);
$results = mysql_num_rows($sql);
//echo '&amp;lt;script&amp;gt;alert(&amp;quot;'.$results.'&amp;quot;)&amp;lt;/script&amp;gt;';
if ($results &amp;gt; 0)
{

for($i=0;$i&amp;lt;$results;$i++)
{
while($rows = mysql_fetch_array($sql))
{
/* print_r($rows['expired_on']);?&amp;gt; &amp;lt;?*/
$exdate = $rows['expired_on'];
$curdate = date('Y-m-d');
$datedif = mysql_query(&amp;quot;select datediff('&amp;quot;.$curdate.&amp;quot;','&amp;quot;.$exdate.&amp;quot;')&amp;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 = &amp;quot;Product Expire Intimation&amp;quot;;
$message = &amp;quot;Dear Mr/Miss/Mrs
The Following Your Product Expired
Product Code:&amp;quot;.$rows['pro_code'].&amp;quot;
Product Name:&amp;quot;.$rows['product_name'].&amp;quot;
Product Expire Date:&amp;quot;.$rows['expired_on'].&amp;quot;&amp;quot;;
$from = &amp;quot;tone@bgrow.com&amp;quot;;
$headers = &amp;quot;From:&amp;quot; . $from;
mail($to,$subject,$message,$headers);
$checkdate = mysql_query(&amp;quot;update supplier_product_det set mailcount ='&amp;quot;.$curdate.&amp;quot;' where id='&amp;quot;.$rows['id'].&amp;quot;'&amp;quot;) or die(mysql_error());
}


//echo $rows['supplier'];

}
if (($date['0'])== 0)
{
if(($rows['mailcount'])!== $curdate)
{
$to = $rows['supplier'];
$subject = &amp;quot;Product Expire Intimation&amp;quot;;
$message = &amp;quot;Dear Mr/Miss/Mrs
The Following Your Product Expired
Product Code:&amp;quot;.$rows['pro_code'].&amp;quot;
Product Name:&amp;quot;.$rows['product_name'].&amp;quot;
Product Expire Date:&amp;quot;.$rows['expired_on'].&amp;quot;&amp;quot;;
$from = &amp;quot;tone@bgrow.com&amp;quot;;
$headers = &amp;quot;From:&amp;quot; . $from;
mail($to,$subject,$message,$headers);
$checkdate = mysql_query(&amp;quot;update supplier_product_det set mailcount ='&amp;quot;.$curdate.&amp;quot;' where id='&amp;quot;.$rows['id'].&amp;quot;'&amp;quot;) or die(mysql_error());
}


//echo $rows['supplier'];

}
if (($date['0'])== -1)
{
if(($rows['mailcount'])!== $curdate)
{
$to = $rows['supplier'];
$subject = &amp;quot;Product Expire Intimation&amp;quot;;
$message = &amp;quot;Dear Mr/Miss/Mrs
The Following Your Product will Expire Today
Product Code:&amp;quot;.$rows['pro_code'].&amp;quot;
Product Name:&amp;quot;.$rows['product_name'].&amp;quot;
Product Expire Date:&amp;quot;.$rows['expired_on'].&amp;quot;&amp;quot;;
$from = &amp;quot;tone@bgrow.com&amp;quot;;
$headers = &amp;quot;From:&amp;quot; . $from;
mail($to,$subject,$message,$headers);
$checkdate = mysql_query(&amp;quot;update supplier_product_det set mailcount ='&amp;quot;.$curdate.&amp;quot;' where id='&amp;quot;.$rows['id'].&amp;quot;'&amp;quot;) or die(mysql_error());
}


//echo $rows['supplier'];

}
}

}

}

}
?&amp;gt;&lt;/code&gt;</code></pre>

tamildinesh
Newbie Poster
2 posts since Jan 2012
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: