MySQL check dates and send a mail when one year old
Hello,
I need a script that checks the databases date colum and send a mail when one year has passed, is it very difficult to do something like that? How do I do that? (it's a linux/unix server)
it's really not that difficult. here's an example:
PHP Code:
//connect to db
$old_date= date("Y")-1;
//assuming the date column contains only the year
$sql = "SELECT email FROM mytable WHERE date='".$old_date."'";
$res = mysql_query($sql) or die("Error");
while($all = mysql_fetch_assoc($res)):
$to = $all[email];
$subject = //your subject;
$message= //your message
$headers= //some extra mail settings
mail($to, $subject, $message, $headers);
endwhile;
Greetz,
UnrealEd
__________________
"Good judgement comes from experience, and experience comes from bad judgement." - Fred Brooks