That's certainly food for thought. I will break it down and test it over the next couple of days. Hopefully you have it and I can get a working model to show by the middle of the week. Thank you, I will let you know how it works out
From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Pete Sent: 13 May 2007 20:23 To: [email protected] Subject: Re: [php-list] after certain date do this.... In message <[EMAIL PROTECTED]>, Mark Mckee <[EMAIL PROTECTED] <mailto:lists%40soddengecko.com> > writes >I have not got a piece of code as I cannot seem to get my head around it. >What I do have is what I am using to extract the data from the database. > > > >When the date is inserted into the database it is formatted like this >14-05-2007 and is displayed the same way. Ah - what sort of database is it? It looks like you might be using MySQL, in which case, you don't seem to be using a date field. Am I correct? I would do it in two steps - the report, and the emails. There isn't really a connection between the two, other than the table is the same one. If the field were a MySQL date field, then it would be: >$sql="SELECT * FROM user_info ORDER BY Start_Date"; Try to name the fields that you are selecting - you will no doubt change them later, when the boss changes their mind, and you should never return more fields than you need. $sql="SELECT Title, First_Name, Last_Name, Department_Name, DATE_FORMAT( Start_Date, '%d-%m-%Y') AS startdate, DATE_ADD(Start_Date, INTERVAL 5 DAY)>NOW() AS overdue FROM user_info ORDER BY start_date"; (note that you will be echoing "startdate", not "Start_Date") >echo " ><tr bgcolor='#F0F5FE'> > echo ($rows['overdue'])?"<tr bgcolor='##FEF0F5'>":"<tr bgcolor='F0F5FE'>"; Then I would write a second and third script, with $sql="SELECT Title, First_Name, Last_Name, Department_Name, Start_Date FROM user_info WHERE Start_Date > NOW() ORDER BY start_date"; and $sql="SELECT Title, First_Name, Last_Name, Department_Name, Start_Date FROM user_info WHERE DATE_ADD(Start_Date, INTERVAL 5 DAY)>NOW() ORDER BY start_date"; and send emails for every record returned. These would usefully be run with a cron job. All untested... <G> -- Pete Clark Sunny Andalucia http://www.hotcosta.com/comm_1.htm [Non-text portions of this message have been removed]
