Current location: Hot Scripts Forums » Programming Languages » PHP » MySQL check dates and send a mail when one year old


MySQL check dates and send a mail when one year old

Reply
  #1 (permalink)  
Old 12-22-05, 11:24 AM
Oskare100 Oskare100 is offline
Newbie Coder
 
Join Date: Apr 2005
Posts: 86
Thanks: 0
Thanked 0 Times in 0 Posts
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)

Best Regards
Oskar R
Reply With Quote
  #2 (permalink)  
Old 12-23-05, 04:29 AM
UnrealEd's Avatar
UnrealEd UnrealEd is offline
Community Liaison
 
Join Date: May 2005
Location: Antwerp, Belgium
Posts: 3,165
Thanks: 4
Thanked 25 Times in 25 Posts
it's really not that difficult. here's an example:

PHP Code:

//connect to db

$old_datedate("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

Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump


All times are GMT -5. The time now is 06:23 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.